网站首页的默认文件是tpl_index_default.php
需要在首页上显示类似兰亭的Featured Categories模块,需要添加以下代码:
-
<table width=100% border=0><tr>
-
<?php
-
$categories_query = "SELECT c.categories_id, cd.categories_name, c.categories_image, c.parent_id
-
FROM " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd
-
WHERE c.parent_id = :parentID
-
AND c.categories_id = cd.categories_id
-
AND cd.language_id = :languagesID
-
AND c.categories_status= '1'
-
ORDER BY sort_order";
-
$categories_query = $db->bindVars($categories_query, ':parentID', $current_category_id, 'integer');
-
$categories_query = $db->bindVars($categories_query, ':languagesID', $_SESSION['languages_id'], 'integer');
-
$categories_row = $db->Execute($categories_query);
-
$number_of_categories = $categories_row->RecordCount();
-
$new_products_category_id = $current_category_id;
-
$rows = 0;
-
while (!$categories_row->EOF) {
-
$rows++;
-
$cPath_new = zen_get_path($categories_row->fields['categories_id']);
-
-
$cPath_new = str_replace('=0_', '=', $cPath_new);
-
$width = (int)(100 / MAX_DISPLAY_CATEGORIES_PER_ROW) . '%';
-
$newrow = false;
-
if ((($rows / MAX_DISPLAY_CATEGORIES_PER_ROW) == floor($rows / MAX_DISPLAY_CATEGORIES_PER_ROW)) && ($rows != $number_of_categories))
-
{
-
$newrow = true;
-
}
-
if (!$categories_row->fields['categories_image']) !$categories_row->fields['categories_image'] = 'pixel_trans.gif';
-
-
-
-
$limit = '3';
-
-
$subs_indent = '• ';
-
-
$no_subs_indent = '» ';
-
$no_subs_prefix = 'View Products';
-
-
-
-
$limit_exceeded_indent = '»» ';
-
$limit_exceeded_prefix = 'More ';
-
-
$parent_id = $categories_row->fields[categories_id];
-
$sql = "select c.categories_id, cd.categories_name
-
from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd
-
where c.parent_id = '" . (int)$parent_id . "'
-
and c.categories_id = cd.categories_id
-
and cd.language_id = '" . (int)$_SESSION['languages_id'] . "'
-
and c.categories_status= '1'
-
order by sort_order, cd.categories_name";
-
$subcats = $db->Execute($sql);
-
$subs_string = "";
-
-
if ($subcats->EOF) $subs_string .= '';
-
while (!$subcats->EOF) {
-
if ($limit == $subcats->cursor) {
-
-
$subs_string .= '';
-
break;
-
}
-
$cPath_subs = $cPath_new . '_' . $subcats->fields[categories_id];
-
$subs_string .= '<br />' . $subs_indent . '<a href=' . zen_href_link(FILENAME_DEFAULT, $cPath_subs) . '>' . $subcats->fields[categories_name] . '</a>';
-
$subcats->MoveNext();
-
}
-
-
?>
-
<td align="center" width="<?php echo $width; ?>" valign="top" style="border-bottom: 1px solid #e5e5e5;">
-
<a href="<?php echo zen_href_link(FILENAME_DEFAULT, $cPath_new); ?>">
-
<?php echo zen_image(DIR_WS_IMAGES . $categories_row->fields['categories_image'], $categories->fields['categories_name'], 80, 80); ?>
-
</a>
-
<br>
-
<b style="font-size:120%;"><?php echo $categories_row->fields['categories_name']; ?></b><br>
-
<span><?php echo $subs_string; ?></span>
-
</td>
-
<?php
-
if ($newrow) {
-
?>
-
</tr>
-
<tr>
-
<?php
-
}
-
?>
-
<?
-
$categories_row->MoveNext();
-
}
-
?>
-
</table>
这段代码就组成了一个模块,需要的时候,调用在你需要显示的地方即可!