<?php
echo theme('imagecache', $preset, $imagepath, $alt, $image_title)
?>在 node.tpl.php 內可用
其中 $preset 是imagecache profile 的 machine name
<?php
echo theme('imagecache', $preset, $imagepath, $alt, $image_title)
?>在 node.tpl.php 內可用
其中 $preset 是imagecache profile 的 machine name
先修文章:
http://joetsuihk.com/node/94
http://joetsuihk.com/node/95
Views 的table header是可以使用 *.tpl.php 修改的,
常見的應用包括使用 icon 而不使用 text 作為 label
只要修改 style output 的 views-view-table.tpl.php
<?php
// $Id: views-view-table.tpl.php,v 1.8 2009/01/28 00:43:43 merlinofchaos Exp $
/**
* @file views-view-table.tpl.php
* Template to display a view as a table.
*
* - $title : The title of this group of rows. May be empty.
* - $header: An array of header labels keyed by field id.
* - $fields: An array of CSS IDs to use for each field id.
* - $class: A class or classes to apply to the table, based on settings.
* - $row_classes: An array of classes to apply to each row, indexed by row
* number. This matches the index in $rows.
* - $rows: An array of row items. Each row is an array of content.
* $rows are keyed by row number, fields within rows are keyed by field ID.
* @ingroup views_templates
*/
?>
<table class="<?php print $class; ?>">
<?php if (!empty($title)) : ?>
<caption><?php print $title; ?></caption>
<?php endif; ?>
<thead>
<tr>
<?php //表格頭輸出開始: ?>
<?php foreach ($header as $field => $label): ?>
<th class="views-field views-field-<?php print $fields[$field]; ?>">
<?php print $label; ?>
</th>
<?php //表格頭輸出完結:?>
<?php endforeach; ?>
</tr>
</thead>
<tbody>
<?php foreach ($rows as $count => $row): ?>
<tr class="<?php print implode(' ', $row_classes[$count]); ?>">
<?php foreach ($row as $field => $content): ?>
<td class="views-field views-field-<?php print $fields[$field]; ?>">
<?php print $content; ?>
</td>
<?php endforeach; ?>
</tr>
<?php endforeach; ?>
</tbody>
</table>看似簡單, 但如果表格頭需要 sortable, 並指示排序方向的話
便要再加一個 if case 檢查 $_GET['order'] 作不同輸出
奇怪 $views 變數之中竟然沒有 sort order 的資料
魔鬼都在細節之中...
續 part1
補一下 table 顯示之下的 theming.

假如你的 table 有4個 fields, views 的 theming information 便有6個 templates:
1個 display 的 tpl (page 或block)
1個 style tpl, 包含了 <table>
每1個 field 都可以有一個自己的 tpl (詳見 attachment)
HTML list (ul, ol) 也是同樣的情況
display + style tpl, 外加每個field 一個tpl
也可以做 field by field 的 tpl, 修改 <ul> 的class, <li>多個 span 之類
最後, 雖然和 views 無關, 但pager 也經常由 views 產生
但 views 的 pager 都是使用 core 的pager, theme_pager()
theme 的時候沒有 tpl, 要在 template.php 修改, 或者使用preprocess 提供 tpl
Recently, i have find some theme-ing functions that cannot be simply find by theme developer module, as that theme function only calls when you are anonymous user.
comment.module theme_comment_post_forbidden() is an example.
This function render the "Please login to post comments" to anonymous user, request them to login in order to get access to the comment form.
As theme developer do not appears when you are not admin, so when i want to theme this sentence, i spend some time to find out the function is defined in comment module, which is reasonable.
Hope this small tips helps someone.
Recent comments
2 weeks 6 days ago
2 weeks 6 days ago
2 weeks 6 days ago
2 weeks 6 days ago
2 weeks 6 days ago
2 weeks 6 days ago
2 weeks 6 days ago
3 weeks 3 days ago
4 weeks 10 hours ago
4 weeks 14 hours ago