开发者

Drupal 6: Theme Developer gives too common candidate name, nothing specific

I'm working on a restaurant directory site. I have restaurant details page that I need to implement gmap, slideshow, etc. So I need a specific page.tpl and Theme Developer gives the info as below

alt text http://img.skitch.com/20100708-b9af98fb8mpckai5wfpmktxwgf.jpg

but site's about us, contact us, faq, etc pages has same candidate name as page-node.tpl.php . So I can't use that :/

Why isnt there anything like page-restaurant.tpl.php

how can I solve this? Appreciate helps so much! thanks a lot!


[SORTED]

  <script type="text/javascript">
    window.onload = function() {
    开发者_开发百科  load();
    }
    window.onunload = function() {
      GUnload();
    }  
  </script>'


If you are just wanting to add Javascript code, you can use the CSS class provided with most themes. For example, Zen will give you

<body class="not-front logged-in node-type-restaurant two-sidebars page-restaurant">...</body>

which you can detect with jQuery as

$(document).ready() { $('.page-restaurant').Myfunction(); }

Regarding slideshow, I've had good luck with Views Slideshow, which provides a block you can just place in a region on your page.


We had a similar question yesterday.

The logic of drupal is that the page should be for the common elements of a page accross all types of page and content types. Page is the top level template, if you are trying to change that per content type you may not have seperated your theme correctly. You have node theming for differentiating between the different types of node. The format is node-[NODE TYPE].tpl.php

Have you created a content type "restaurant"? If you do this, you may find modules like gmap will help you out.


Add the following function to your template.php file. Replace "themename" with the actual name of your theme. This assumes you've created a separate content type for "restaurant" - I gather you have from the previous answers and comments. You'll get an option to use page-restaurant.tpl.php once you upload the edited template.php file and refresh the theme registry.

function themename_preprocess(&$vars, $hook) {
    switch ($hook){
        case 'page':
          // Add a content-type page template in second to last.
            if ('node' == arg(0)) {
                $node_template = array_pop($vars['template_files']);
                $vars['template_files'][]  = 'page-' . $vars['node']->type;
                $vars['template_files'][]  = $node_template;
            }
            break;

    }
    return $vars;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜