网站首页的默认文件是tpl_index_default.php
需要在首页上显示类似兰亭的Featured Categories模块,
<table width=100% border=0><tr>
<?php
$categories_query = "SELECT c.categories_id, cd.categories_name, c.categories_p_w_picpath, 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']);
// strio out 0_ from top level
$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_p_w_picpath']) !$categories_row->fields['categories_p_w_picpath'] = 'pixel_trans.gif';
// start amazon style sub-cats in category lists
// start config variables
// display limit - adjust $limit to the number of subcats to display under parent category (4 or 5 seems right)
$limit = '3';
// subcat prefix - enter your preferred subcat prefix (bullets are default)
$subs_indent = '• ';
// no sub-cats - display this if there are no sub-cats within a category. Leave both values blank (see below) if you want to display only the category name
$no_subs_indent = '» ';
$no_subs_prefix = 'View Products';
//$no_subs_indent = '';
//$no_subs_prefix = '';
// sub-cats exceed display limit - indent and text prefix to display if sub-cats exceed display limit (eg - More {CATEGORY NAME})
$limit_exceeded_indent = '»» ';
$limit_exceeded_prefix = 'More ';
// end config variables
$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 .= '<br />' . $no_subs_indent . '<a href=' . zen_href_link(FILENAME_DEFAULT, $cPath_new) . '>' . $no_subs_prefix . '</a>';
if ($subcats->EOF) $subs_string .= '';
while (!$subcats->EOF) {
if ($limit == $subcats->cursor) {
//$subs_string .= '<br />' . $limit_exceeded_indent . '<a href=' . zen_href_link(FILENAME_DEFAULT, $cPath_new) . '>' . $limit_exceeded_prefix . $categories_row->fields[categories_name] . '</a>';
$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();
}
// end add sub-cat bullets to category rows
?>
<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_p_w_picpath(DIR_WS_IMAGES . $categories_row->fields['categories_p_w_picpath'], $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>
ZENCART首页显示 Featured Categorie的方法
原创
©著作权归作者所有:来自51CTO博客作者luo620的原创作品,请联系作者获取转载授权,否则将追究法律责任
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
magento 首页添加随机产品 add a Random Featured Product list on home page in Magento
want to show products from a specific category on your home page you can do this simply with{{block type="catalog/product_list" category_id="12" template="catalog/product/list.phtml"}} on your h...
php javascript ViewUI html CMS -
maven项目首页显示的问题
最近无聊,自己就想着虽然自己试一个程序员,但是一开始用的是公司的框架,但是真正的自己去搭建一个框架却没有于是我想自己去创的创...
java maven helloworld maven项目 xml -
zencart的文件结构
zencart的文件结构
list 网络 php 数组 文件结构