Template files are searched in the following order:
[list]
[*] block-[module]-[delta].tpl.php
[*] block-[module].tpl.php
[*] block-[region].tpl.php
[*] block.tpl.php
[/list]
For example, the user login block has a delta of '0'. If you put it in the left sidebar, when it's rendered, PHPTemplate will search for the following templates in descending order:
[list]
[*]
[*] block-user-0.tpl.php
[*] block-user.tpl.php
[*] block-left.tpl.php
[*] block.tpl.php
[/list]
You can find the block's module and delta by looking at the html source of a page: each block's main DIV has the following classes and IDs:
[list]
[*] block-[module]-[delta].tpl.php
[*] block-[module].tpl.php
[*] block-[region].tpl.php
[*] block.tpl.php
[/list]
For example, the user login block has a delta of '0'. If you put it in the left sidebar, when it's rendered, PHPTemplate will search for the following templates in descending order:
[list]
[*]
[*] block-user-0.tpl.php
[*] block-user.tpl.php
[*] block-left.tpl.php
[*] block.tpl.php
[/list]
You can find the block's module and delta by looking at the html source of a page: each block's main DIV has the following classes and IDs:
<div class="block block-<?php print $block->module; ?>"
id="block-<?php print $block->module; ?>-
<?php print $block->delta; ?>">
<h2 class="title"><?php print $block->subject; ?></h2>
<div class="content"><?php print $block->content; ?></div>
</div>
本文介绍了PHP模板系统中模板文件的搜索顺序。系统首先查找带有模块名和增量值的特定模板,然后逐步降低到更通用的模板。通过查看页面的HTML源代码可以找到每个区块对应的模块名和增量值。
803

被折叠的 条评论
为什么被折叠?



