Пример #1
0
/**
 * Preprocessor for page.tpl.php template file.
 */
function my_theme_preprocess_page(&$vars, $hook)
{
    kpr($vars);
    //dsm($vars);
    if (!empty($vars['node']) && $vars['node']->nid == 3) {
        $vars['site_name'] = 'Changed header';
        $vars['title'] = 'Exampletemplate_preprocess_page';
    }
    // For easy printing of variables.
    $vars['logo_img'] = '';
    if (!empty($vars['logo'])) {
        $vars['logo_img'] = theme('image', array('path' => $vars['logo'], 'alt' => t('Home'), 'title' => t('Home')));
    }
    $vars['linked_logo_img'] = '';
    if (!empty($vars['logo_img'])) {
        $vars['linked_logo_img'] = l($vars['logo_img'], '<front>', array('attributes' => array('rel' => 'home', 'title' => t('Home')), 'html' => TRUE));
    }
    $vars['linked_site_name'] = '';
    if (!empty($vars['site_name'])) {
        $vars['linked_site_name'] = l($vars['site_name'], '<front>', array('attributes' => array('rel' => 'home', 'title' => t('Home'))));
    }
    // Site navigation links.
    $vars['main_menu_links'] = '';
    if (isset($vars['main_menu'])) {
        $vars['main_menu_links'] = theme('links__system_main_menu', array('links' => $vars['main_menu'], 'attributes' => array('id' => 'main-menu', 'class' => array('inline', 'main-menu')), 'heading' => array('text' => t('Main menu'), 'level' => 'h2', 'class' => array('element-invisible'))));
    }
    $vars['secondary_menu_links'] = '';
    if (isset($vars['secondary_menu'])) {
        $vars['secondary_menu_links'] = theme('links__system_secondary_menu', array('links' => $vars['secondary_menu'], 'attributes' => array('id' => 'secondary-menu', 'class' => array('inline', 'secondary-menu')), 'heading' => array('text' => t('Secondary menu'), 'level' => 'h2', 'class' => array('element-invisible'))));
    }
}
 /**
  * Returns a dump of a route object.
  *
  * @param \Symfony\Component\HttpFoundation\Request $request
  *   Page request object.
  * @param \Drupal\Core\Routing\RouteMatchInterface $route_match
  *   The route match.
  *
  * @return array
  *   A render array containing the route object.
  */
 public function menuItem(Request $request, RouteMatchInterface $route_match)
 {
     $output = [];
     // Get the route object from the path query string if available.
     if ($path = $request->query->get('path')) {
         try {
             /* @var \Symfony\Cmf\Component\Routing\ChainRouter $router */
             $router = \Drupal::service('router');
             $route = $router->match($path);
             $output['route'] = ['#markup' => kpr($route, TRUE)];
         } catch (\Exception $e) {
             drupal_set_message($this->t("Unable to load route for url '%url'", ['%url' => $path]), 'warning');
         }
     } else {
         $route = $route_match->getRouteObject();
         $output['route'] = ['#markup' => kpr($route, TRUE)];
     }
     return $output;
 }
Пример #3
0
/**
 * Hier de code voor de node--article.tpl.php file
 *<div class="content"<?php print $content_attributes; ?»
 *<div class="dateblock"›
 *<span class="month"><?php print $submitted_month; ?></span>
 *<span class="day"><?php print $submitted_day; ?></span>
 *<span class="year"><?php print $submitted_yead; ?></span>
 *</div>
 */
function theme_preprocess_node(&$variables)
{
    //dit om de aanmaak datum te lay-outen, de bijhorende node--article.tpl.php
    // juist hierboven in comment
    if ($variables['type'] == 'article') {
        $node = $variables['node'];
        $variables['submitted_day'] = format_date($node->created, 'custom', 'j');
        $variables['submitted_month'] = format_date($node->created, 'custom', 'M');
        $variables['submitted_year'] = format_date($node->created, 'custom', 'Y');
    }
    // hier voor een aangepaste versie voor de dag van de week er wordt hier een
    // node--dag.tpl.php aangemaakt zou dit ook kunnen gebruiken voor de bepaalde periodes
    // van het jaar bv kerst een aangepaste versie de tpl controleren hierna een aparte .css
    // file laden bijvoorbeeld
    if ($variables['type'] == 'page') {
        $today = strtolower(date('l'));
        $variables['theme_hook_suggestions'] = 'node__' . $today;
        $variables['day_of_the_week'] = $today;
        kpr($variables);
    }
}
Пример #4
0
 * - $page['triptych_last']: Items for the last triptych.
 * - $page['footer_firstcolumn']: Items for the first footer column.
 * - $page['footer_secondcolumn']: Items for the second footer column.
 * - $page['footer_thirdcolumn']: Items for the third footer column.
 * - $page['footer_fourthcolumn']: Items for the fourth footer column.
 * - $page['footer']: Items for the footer region.
 *
 * @see template_preprocess()
 * @see template_preprocess_page()
 * @see template_process()
 * @see bartik_process_page()
 * @see html.tpl.php
 */
?>
 <?php 
kpr(get_defined_vars());
?>
<div id="page-wrapper"><div id="page">

  <div id="header" class="<?php 
print $secondary_menu ? 'with-secondary-menu' : 'without-secondary-menu';
?>
"><div class="section clearfix">

    <?php 
if ($logo) {
    ?>
      <a href="<?php 
    print $front_page;
    ?>
" title="<?php 
Пример #5
0
<!--[if IE 8]>    <html class="lt-ie9" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html lang="en"> <!--<![endif]-->
<head>
<meta charset="utf-8" />
<meta http-equiv="x-ua-compatible" content="ie=edge, chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title><?php 
print $head_title;
?>
</title>
<?php 
if (theme_get_setting('toggle_favicon')) {
    $favicon = theme_get_setting('favicon');
} else {
    $favicon = path_to_theme() . "/img/favicon.ico";
    kpr($favicon);
}
?>
<link rel="shortcut icon" type="image/x-icon" href="<?php 
print $favicon;
?>
" />
<?php 
print $styles;
print $scripts;
?>
</head>
<body class="<?php 
print $classes;
?>
" <?php 
       if (isset($extra[$c])) {
           ?>
       <div class="mobile-story-list-item mobile-story-list-item-extra">
         <?php 
           echo $extra[$c];
           ?>
       </div>
     <?php 
       }
       ?>
     
     <div class="mobile-story-list-item">
       <div class="info">
         <div class="category">
           <?php 
       kpr($item);
       die;
       echo $item['category'];
       ?>
         </div>
         <h2 class="title">
           <?php 
       echo $item['title'];
       ?>
         </h2>
       </div>
     </div>
   <?php 
   }
   ?>
 <?php 
Пример #7
0
/**
 * Preprocess functions for node.tpl.php.
 */
function base_preprocess_node(&$vars)
{
    $node = $vars['node'];
    $options = array('absolute' => TRUE);
    $nid = $vars['vid'];
    // Node ID
    $url = url('node/' . $nid, $options);
    $vars['theme_hook_suggestions'][] = 'node__' . $vars['view_mode'];
    $vars['theme_hook_suggestions'][] = 'node__' . $vars['type'] . '__' . $vars['view_mode'];
    // GENERAL VARS ====================================================
    $vars['body'] = render($vars['content']['body']);
    $vars['created'] = format_date($vars['created'], 'custom', "n/j/y");
    $vars['sections'] = render($vars['content']['field_section']);
    $vars['tags'] = render($vars['content']['field_tags']);
    $vars['service_links'] = render($vars['content']['service_links']);
    $vars['video'] = render($vars['content']['field_video_url']);
    if ($vars['view_mode'] == 'teaser') {
        $vars['title'] = l(html_entity_decode($vars['title']), $url, array('html' => TRUE));
        $vars['cover_image'] = render($vars['content']['field_cover_image']);
        if ($vars['type'] == 'video') {
            $vars['cover_image'] = render($vars['content']['field_video_url']);
        }
    }
    // IMAGE GALLERY ====================================================
    if ($vars['type'] == 'image_gallery') {
        if ($vars['view_mode'] == 'teaser') {
            $vars['cover_image'] = render($vars['content']['field_cover_image']);
            if (isset($vars['cover_image'])) {
                $vars['cover_image'] = l($vars['cover_image'], $url, array('html' => TRUE));
            } else {
                $vars['cover_image'] = l(render_image($vars['field_other_images'][0], 'cover_image'), $url, array('html' => TRUE));
            }
            $read_more = l(' — read more', $url);
            $summary_text = render($vars['content']['body']);
            $vars['summary'] = $summary_text . '  ' . $read_more;
        }
        if ($vars['view_mode'] == 'full') {
            $images = array();
            for ($i = 0; $i < count($vars['field_other_images']); $i++) {
                $image = render_image($vars['field_other_images'][$i], 'gallery_large');
                if ($vars['field_other_images'][$i]['linknext'][1]) {
                    $caption1 = '<div class="caption c-left">' . $vars['field_other_images'][$i]['title'] . '</div>';
                    $iw = $vars['field_other_images'][$i]['width'];
                    $i++;
                    $caption2 = '<div class="caption c-right">' . $vars['field_other_images'][$i]['title'] . '</div>';
                    $iw2 = $vars['field_other_images'][$i]['width'];
                    $wt = $iw + $iw2;
                    $image2 = render_image($vars['field_other_images'][$i], 'gallery_large');
                    $images[] = '<div class="image-group" data-wt="' . $wt . '">' . $image . $image2 . '<div class="captions">' . $caption1 . $caption2 . '</div></div>';
                } else {
                    $caption = '<div class="captions"><div class="caption">' . $vars['field_other_images'][$i]['title'] . '</div></div>';
                    $images[] = '<div class="single-image">' . $image . $caption . '</div>';
                }
            }
            $gallery_settings = array('autoplay' => $vars['field_autoplay_slideshow'][0]['value'], 'start_thumbs' => $vars['field_start_with_thumbnails'][0]['value'], 'hide_controls' => $vars['field_hide_controls'][0]['value']);
            drupal_add_js(array('gallery_settings' => $gallery_settings), 'setting');
            $vars['images'] = theme_item_list(array('items' => $images, 'title' => null, 'type' => 'ul', 'attributes' => array()));
            drupal_add_js(path_to_theme() . '/js/init_gallery.js');
        }
        kpr($vars);
    }
    // ARTICLE ====================================================
    if ($vars['type'] == 'article') {
        $vars['cover_image'] = render($vars['content']['field_cover_image']);
        $vars['post_date'] = $vars['created'];
        $vars['tags'] = render($vars['content']['field_tags']);
        $vars['summary'] = render($vars['content']['body']);
        $vars['service_links'] = render($vars['content']['service_links']);
        $vars['comment_count'] = l('Comments ' . $vars['comment_count'], $url . '#comments');
        if ($vars['view_mode'] == 'teaser') {
            //$vars['title'] = l($vars['title'], $url);
            $vars['cover_image'] = l($vars['cover_image'], $url, array('html' => TRUE));
            $read_more = l(' — read more', $url);
            $summary_text = render($vars['content']['body']);
            $vars['summary'] = $summary_text . '  ' . $read_more;
        }
        //kpr($vars);
    }
}
Пример #8
0
function bartik_preprocess_page(&$vars)
{
    kpr($vars['node']);
    if ($vars['node']->type == 'restaurant_page') {
        $vars['title'] = false;
    }
}