Guest User

Untitled

a guest
May 27th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.31 KB | None | 0 0
  1. <?php
  2. /**
  3.  * @file
  4.  * Provide custom breadcrumbs for node-type pages and base functionality
  5.  * for submodules to add custom breadcrumbs for other types of pages.
  6.  */
  7.  
  8. /**
  9.  * Implements hook_init().
  10.  */
  11. function cve_breadcrumbs_init() {
  12.   global $language;
  13.   $lang_name = $language->language;
  14.   $url = explode('/', drupal_lookup_path('alias', $_GET['q']));
  15.   $urlq = explode('/', $_GET['q']);
  16.   $breadcrumb = array();
  17.   //print_r("URL=". $url);
  18.   //print_r("q=". $_GET['q']);
  19.   //This first link is overriden, but we have to define it.
  20.   $breadcrumb[] = l('Home', '<front>');
  21.   //Switch according to the language
  22.   switch ($lang_name) {
  23.     case 'en' :
  24.       //If we are on the first level, and the second level is empty, we 'can set the title of the page and no link
  25.       switch ($url[0]) {
  26.         case 'the-project':
  27.           $breadcrumb[] = l('The Project', 'the-project');
  28.           break;
  29.         case 'blog-1':
  30.           $breadcrumb[] = l('Blog', 'blog-1');
  31.           break;
  32.         case 'reading-room':
  33.           $breadcrumb[] = l('Reading Room', 'reading-room');
  34.           break;
  35.         case 'centers-and-organizations' :
  36.           $breadcrumb[] = l('Centers and Organizations', 'centers-and-organizations');
  37.           break;
  38.         case 'contact' :
  39.           $breadcrumb[] = l('Contact', 'contact');
  40.           break;
  41.         case 'legal-terms' :
  42.           $breadcrumb[] = l('Legal Terms', 'legal-terms');
  43.           break;
  44.       }
  45.       //If there is no alias (it is a view), we have to work directly with the arguments from q
  46.       if ($url[0]=='') {
  47.           switch ($urlq[0]) {
  48.         case 'eventos':
  49.           $breadcrumb[] = l('Events', 'eventos');
  50.           break;
  51.         case 'centros-y-organizaciones' :
  52.           $breadcrumb[] = l('Centers and Organizations', 'centros-y-organizaciones');
  53.           break;
  54.         case 'search' :
  55.           $breadcrumb[] = l('Search', 'search');
  56.           break;
  57.           }
  58.       }
  59.       break;
  60.     case 'es' :
  61.       //If we are on the first level, and the second level is empty, we 'can set the title of the page and no link
  62.       switch ($url[0]) {
  63.         case 'el-proyecto':
  64.           $breadcrumb[] = l('El Proyecto', 'el-proyecto');
  65.           break;
  66.         case 'blog':
  67.           $breadcrumb[] = l('Blog', 'blog');
  68.           break;
  69.         case 'banco-de-documentacion':
  70.           $breadcrumb[] = l('Banco de Documentación', 'banco-de-documentacion');
  71.           break;
  72.         case 'centros-y-organizaciones' :
  73.           $breadcrumb[] = l('Centros y Organizaciones', 'centros-y-organizaciones');
  74.           break;
  75.         case 'contacto' :
  76.           $breadcrumb[] = l('Contacto', 'contacto');
  77.           break;
  78.         case 'terminos-legales' :
  79.           $breadcrumb[] = l('Términos Legales', 'terminos-legales');
  80.           break;
  81.       }
  82.       //If there is no alias (it is a view), we have to work directly with the arguments from q
  83.       if ($url[0]=='') {
  84.           switch ($urlq[0]) {
  85.         case 'eventos':
  86.           $breadcrumb[] = l('Eventos', 'eventos');
  87.           break;
  88.         case 'centros-y-organizaciones' :
  89.           $breadcrumb[] = l('Centros y Organizaciones', 'centros-y-organizaciones');
  90.           break;
  91.         case 'search' :
  92.           $breadcrumb[] = l('Búsqueda', 'search');
  93.           break;
  94.           }
  95.       }
  96.       break;
  97.     case 'pt' :
  98.       break;
  99.   }
  100.   // Set Breadcrumbs
  101.   drupal_set_breadcrumb($breadcrumb);
  102. }
Add Comment
Please, Sign In to add comment