Created
August 26, 2014 19:25
-
-
Save labboy0276/439d1c845ee56388e161 to your computer and use it in GitHub Desktop.
Adds Variant for Panels
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Implements hook_entity_info_alter(). | |
*/ | |
function panelizer_variant_entity_info_alter(&$entity_info) { | |
$entity_info['node']['view modes']['doctoral_programs'] = array( | |
'label' => t('Doctoral Programs'), | |
'custom settings' => TRUE, | |
); | |
$entity_info['node']['view modes']['ms_minors'] = array( | |
'label' => t('MS Minors'), | |
'custom settings' => TRUE, | |
); | |
$entity_info['node']['view modes']['ms_program'] = array( | |
'label' => t('MS Program'), | |
'custom settings' => TRUE, | |
); | |
$entity_info['node']['view modes']['ms_specialty_area'] = array( | |
'label' => t('MS Specialty Area'), | |
'custom settings' => TRUE, | |
); | |
$entity_info['node']['view modes']['special_studies'] = array( | |
'label' => t('Special Studies'), | |
'custom settings' => TRUE, | |
); | |
} | |
/** | |
* Implements hook_entity_view_mode_alter(). | |
*/ | |
function panelizer_variant_entity_view_mode_alter(&$view_mode, $context) { | |
if ($context['entity']->type == 'academic_programs') { | |
$taxonomy_term = $context['entity']->field_ap_program['und'][0]['taxonomy_term']->name; | |
switch($taxonomy_term) { | |
case 'MS Minors': | |
$view_mode = 'ms_minors'; | |
break; | |
case 'Doctoral Programs': | |
$view_mode = 'doctoral_programs'; | |
break; | |
case 'MS Program': | |
$view_mode = 'ms_program'; | |
break; | |
case 'MS Specialty Area': | |
$view_mode = 'ms_specialty_area'; | |
break; | |
case 'Special Studies': | |
$view_mode = 'special_studies'; | |
break; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment