Commit dae80266 authored by Eric Bremner's avatar Eric Bremner
Browse files

FDSU-1829: Adding homepage banners to the virtual site homepage and adding comments.

parent d33f9709
......@@ -6,6 +6,71 @@
include_once 'uw_virtual_site_homepage.features.inc';
/**
* Implements hook_field_widget_form_alter().
* Adding process to image types to change title to caption for homepage banners.
*/
function uw_virtual_site_homepage_field_widget_form_alter(&$element, &$form_state, $context) {
if($context['field']['type'] == 'image') {
//dsm($context['field']['type']);
}
if($context['field']['type'] == 'image') {
foreach(element_children($element) as $key => $child) {
if($element[$key]['#description'] == 'Provide banner images for virtual site homepages on Scholar at Waterloo sites.') {
$element[$key]['#process'][] = 'uw_virtual_site_homepage_image_field_widget_process';
}
}
}
}
/**
* Implements hook_image_field_widget_process().
* Processing images to change title to caption for homepage banners.
*/
function uw_virtual_site_homepage_image_field_widget_process($element, &$form_state, $form) {
// Set the title to be the caption and the description.
$element['title']['#title'] = 'Caption';
$element['title']['#description'] = 'The caption is display with the picture.';
// Return the altered element
return $element;
}
/**
* Implements hook_page_alter().
* Placing homepage banners on the virtual site homepage.
*/
function uw_virtual_site_homepage_page_alter(&$page) {
$index = 0;
$continue = true;
if(isset($page['uw-virtual-site-homepage']['field_uw_home_page_banners'][$index])) {
$html = '<div class="field-name-field-uw-home-page-banners">';
$html .= '<div class="field-items">';
while($continue) {
$html .= '<figure class="field-item uw-homepage-banners-figure">';
$html .= '<img src="' . file_uri_target($page['uw-virtual-site-homepage']['field_uw_home_page_banners'][$index]['#item']['uri']) . '">';
if(isset($page['uw-virtual-site-homepage']['field_uw_home_page_banners'][$index]['#item']['title'])) {
if($page['uw-virtual-site-homepage']['field_uw_home_page_banners'][$index]['#item']['title'] !== "") {
$html .= '<span class="banner-caption">' . $page['uw-virtual-site-homepage']['field_uw_home_page_banners'][$index]['#item']['title'] . '</span>';
}
}
$html .= '</figure>';
$index++;
if(!(isset($page['uw-virtual-site-homepage']['field_uw_home_page_banners'][$index]))) {
$continue = false;
}
}
$html .= '</div>';
$html .= '</div>';
}
$page['uw_virtual_page_homepage_banners_html'] = $html;
}
/**
* Implements hook_FORMID_form_alter().
* Removing options and placing data on the form for setting the virtual homepage.
*/
function uw_virtual_site_homepage_form_uw_virtual_site_homepage_node_form_alter(&$form, &$form_state, $form_id) {
global $base_path;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment