views:

48

answers:

3

Hi friends,

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

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>'
+1  A: 

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.

Jeremy French
Thanks for giving time Jeremy! I already have node-restaurant.tpl.php to edit content part, but I also need page.tpl since I need to add some js to <body tag and some other things :/
artmania
Can you detail what you need to do in the question, for example adding js can be done with drupal_add_js rather than the template.
Jeremy French
If you don't need to do *heavy* altering, there is no need to touch the page.tpl. There are functions for most of this stuff e.g. to add javascript, use http://api.drupal.org/api/function/drupal_add_js/6
DrColossos
I need to add some <body onload="" unonload="">
artmania
+2  A: 

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.

Keith Morgan
A: 

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;
}
Jared