├── context_breadcrumb_current_page.info ├── context_breadcrumb_current_page.module └── plugins └── context_breadcrumb_current_page_reaction.inc /context_breadcrumb_current_page.info: -------------------------------------------------------------------------------- 1 | core = "7.x" 2 | description = "Add Context Reaction that addes the current page to the end of breadcrumbs" 3 | name = "Context Breadcrumb Current Page" 4 | package = "Context" 5 | -------------------------------------------------------------------------------- /context_breadcrumb_current_page.module: -------------------------------------------------------------------------------- 1 | array( 9 | 'path' => drupal_get_path('module', 'context_breadcrumb_current_page') .'/plugins', 10 | 'file' => 'context_breadcrumb_current_page_reaction.inc', 11 | 'class' => 'context_breadcrumb_current_page_reaction', 12 | 'parent' => 'context_reaction', 13 | ), 14 | ); 15 | return $plugins; 16 | } 17 | 18 | 19 | /* 20 | * implemntation of hook_context_registry() 21 | */ 22 | function context_breadcrumb_current_page_context_registry() { 23 | return array( 24 | 'reactions' => array( 25 | 'breadcrumb_current_page' => array( 26 | 'title' => t('Breadcrumb Current Page'), 27 | 'description' => 'Include the current page in the breadcrumb', 28 | 'plugin' => 'context_breadcrumb_current_page_reaction', 29 | ), 30 | ), 31 | ); 32 | } 33 | 34 | /* 35 | * implemntation of hook_process_page() 36 | */ 37 | function context_breadcrumb_current_page_preprocess_page(&$vars) { 38 | if ($plugin = context_get_plugin('reaction', 'breadcrumb_current_page')) { 39 | $plugin->execute($vars); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /plugins/context_breadcrumb_current_page_reaction.inc: -------------------------------------------------------------------------------- 1 | fetch_from_context($context); 10 | $form = array( 11 | 'breadcrumb_show_current_page' => array( 12 | '#title' =>'Show the Current Page in the Breadcrumbs', 13 | '#description' => t('Have the last element in the breadcrumbs be the current page title.'), 14 | '#type' => 'checkbox', 15 | '#default_value' => isset($values['breadcrumb_show_current_page']) ? $values['breadcrumb_show_current_page'] : '', 16 | ), 17 | 'breadcrumb_show_current_page_title' => array( 18 | '#title' =>'Title Override', 19 | '#description' => t('Show this as the breadcrumb title'), 20 | '#type' => 'textfield', 21 | '#default_value' => isset($values['breadcrumb_show_current_page_title']) ? $values['breadcrumb_show_current_page_title'] : '', 22 | ), 23 | 'breadcrumb_show_current_page_only' => array( 24 | '#title' =>'Remove parent Breadcrumbs except for Home', 25 | '#description' => t('Have the only item in the breadcrumbs be the title.'), 26 | '#type' => 'checkbox', 27 | '#default_value' => isset($values['breadcrumb_show_current_page_only']) ? $values['breadcrumb_show_current_page_only'] : '', 28 | ), 29 | 'empty_all_breadcrumbs' => array( 30 | '#title' =>'Hide all Breadcrumbs', 31 | '#description' => t("Don't show any breadcrumbs on this page."), 32 | '#type' => 'checkbox', 33 | '#default_value' => isset($values['empty_all_breadcrumbs']) ? $values['empty_all_breadcrumbs'] : '', 34 | ), 35 | ); 36 | return $form; 37 | } 38 | 39 | function execute(&$vars) { 40 | 41 | foreach ($this->get_contexts() as $k => $v) { 42 | $breadcrumb = drupal_get_breadcrumb(); 43 | if ((isset($v->reactions[$this->plugin])) && 44 | ($v->reactions[$this->plugin]['breadcrumb_show_current_page'])) { 45 | if ($v->reactions[$this->plugin]['breadcrumb_show_current_page_only']) { 46 | $breadcrumb = array($breadcrumb[0]); 47 | } 48 | $title = 49 | $v->reactions[$this->plugin]['breadcrumb_show_current_page_title']? 50 | $v->reactions[$this->plugin]['breadcrumb_show_current_page_title']: 51 | drupal_get_title(); 52 | $breadcrumb[] = $title; 53 | } 54 | if ($v->reactions[$this->plugin]['empty_all_breadcrumbs']) { 55 | //debug($breadcrumb); 56 | $breadcrumb = array(); 57 | } 58 | drupal_set_breadcrumb($breadcrumb); 59 | } 60 | } 61 | } 62 | --------------------------------------------------------------------------------