开发者

drupal---the $page variable node.tpl.php

开发者 https://www.devze.com 2023-01-26 09:22 出处:网络
<?php if (!$page): ?> <h2 class=\"title\"><a href=\"<?php print $node_url; ?>\"><?php print $title; ?></a></h2>
 <?php if (!$page): ?>
  <h2 class="title"><a href="<?php print $node_url; ?>"><?php print $title; ?></a></h2>
   <?php endif; ?>

the code is used to make a decision if the displayed page is a full page state. if $page is true( a full page state) , then !$page is false. the following code is executed. but i saw the following code's result is output to the full page state not the node's page. why?

i find in each article's page. the article's tilte is controled by the page.tpl.php. why it's not controled by the 开发者_运维技巧node.tpl.php. as a fact, an article is a node,which shows should control by the node.tpl.php


In page.tpl.php there you are also printing <?php print $title ?> which prints the title of the page, not the node, which is either a node/article is $page is true, or the username in case you're viewing http://mysite.com/user page, or "Request new password" in case you are on the http://mysite.com/user/password page.

It's because of this you shouldn't print the title in node.tpl.php if the $page is true, because this will print the title twice.

The node/article title should only be printed as a linked title when $page is false, so it's printed along with the node teaser or body, and the page title in this case will be the main title printed from page.tpl.php.

0

精彩评论

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