1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Working With Template Suggestions

Discussion in 'Drupal' started by pom4ik, Feb 12, 2013.

  1. #1
    Hi,

    I have created a new content type called "din_page" and added the following code to template.php file function function THEMENAME_preprocess_page(&$variables)

    
    if (isset($variables['node'])) {
            if ($variables['node']->type == 'din_page'){
                $variables['theme_hook_suggestion'] = 'din__page';
     }
    
    PHP:
    and created a new template file din--page.tpl.php
    When the page loads I see the following in Theme Developer:
    [​IMG]

    This suggests that din--page.php should be loaded ... but it doesn't it load page.tpl.php

    Did I miss anything?

    I am new to Drupal

    Thanks,
    R
     

    Attached Files:

    pom4ik, Feb 12, 2013 IP
  2. duckz

    duckz Active Member

    Messages:
    245
    Likes Received:
    3
    Best Answers:
    1
    Trophy Points:
    68
    #2
    you are passing theme_hook_suggestion as a string when it should be an array

    $variables['theme_hook_suggestions'][] = 'page__din';

    see : http://drupal.org/node/223440 for more information about this.
     
    duckz, Feb 13, 2013 IP
  3. pom4ik

    pom4ik Greenhorn

    Messages:
    31
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    16
    #3
    I changed it it to ...
    
    if ($vars['node']->type == 'din_page'){
                $vars['theme_hook_suggestions'][] = 'din__page';
    }
    PHP:
    Still getting page.tpl.php loaded. this is what I see in Theme Developer
    din--page.tpl.php < page--node--2.tpl.php < page--node--%.tpl.php < page--node.tpl.php < page.tpl.php

    and I did make sure the file is in the right directory.

    thanks
     
    pom4ik, Feb 13, 2013 IP
  4. duckz

    duckz Active Member

    Messages:
    245
    Likes Received:
    3
    Best Answers:
    1
    Trophy Points:
    68
    #4
    change it to page__din_page and see if it is working and template file to page--din-page.tpl.php
     
    duckz, Feb 16, 2013 IP