我會創建一個views-view-table-Temp.tpl.php(其中Temp是視圖名稱),根據日期插入類中。下面是一個例子,我將創建的日期更改爲顯示Time Ago,並在帶有stripos的Week或Day上搜索。您可以使用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 foreach ($header as $field => $label): ?>
<th class="views-field views-field-<?php print $fields[$field]; ?>">
<?php print $label; ?>
</th>
<?php endforeach; ?>
</tr>
</thead>
<tbody>
<?php foreach ($rows as $count => $row): ?>
<tr class="<?php print implode(' ', $row_classes[$count]); ?> <?php
if(stripos($row["created"], "Week")) {
print "week-class ";
}
if(stripos($row["created"], "Day")) {
print "day-class ";
}?>
">
<?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>
在這個例子中,你如何生成表?使用模板(tpl.php)文件?或通過使用另一個模塊? – dusan 2010-01-06 17:49:16
Views模塊 - 我不介意編寫SQL - 但我喜歡視圖的靈活性 - 例如參數,塊,簡單的ajax等...... – tpow 2010-01-11 07:06:51