1

我在一个餐厅目录网站上工作。我有餐厅详细信息页面,我需要实现 gmap、幻灯片等。所以我需要一个特定的 page.tpl,主题开发人员提供如下信息

替代文字 http://img.skitch.com/20100708-b9af98fb8mpckai5wfpmktxwgf.jpg

但网站的关于我们、联系我们、常见问题解答等页面的候选名称与page-node.tpl.php 相同。所以我不能使用它:/

为什么没有像page-restaurant.tpl.php这样的东西

我该如何解决这个问题?欣赏帮助很大!多谢!


[排序]

  <script type="text/javascript">
    window.onload = function() {
      load();
    }
    window.onunload = function() {
      GUnload();
    }  
  </script>'
4

3 回答 3

2

如果您只想添加 Javascript 代码,您可以使用大多数主题提供的 CSS 类。例如,禅会给你

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

你可以用 jQuery 检测到

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

关于幻灯片,我对Views Slideshow很幸运,它提供了一个块,您可以将其放置在页面的某个区域中。

于 2010-07-08T11:57:34.163 回答
1

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.

于 2010-07-08T11:02:36.160 回答
1

将以下函数添加到您的 template.php 文件中。将“themename”替换为您的主题的实际名称。这假设您已经为“餐厅”创建了一个单独的内容类型 - 我从以前的答案和评论中收集到您。上传编辑后的 ​​template.php 文件并刷新主题注册表后,您将获得使用 page-restaurant.tpl.php 的选项。

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;
}
于 2010-07-08T22:19:34.537 回答