Вы не авторизованы.
Добрый день. Заказчику понадобилась кнопка "Каталог", ведущая на страницу со списком категорий, как на главной. Как этот каталог вывести на отдельную страницу? Такого функционала не предусмотрено?
Неактивен
В index.php
Перед:
if (!isset($_SESSION["vote_completed"])) $_SESSION["vote_completed"] = array();
Добавьте:
if( isset($_GET["catalog"]) ) $show_catalog = 1;
Создайте файл catalog.php с таким содержимым:
<?php
if( isset($show_catalog) && $show_catalog == 1 )
{
//get root categories to be shown in the front-end homepage
$q = db_query("SELECT categoryID, name, products_count, picture FROM ".CATEGORIES_TABLE." WHERE categoryID<>0 and parent=0 ORDER BY name") or die (db_error());
$root = array();
while ($row = db_fetch_row($q))
{
if (!file_exists("./products_pictures/$row[3]")) $row[3] = "";
$root[] = $row;
}
//get subcategories of root categories
$query = "SELECT categoryID FROM ".CATEGORIES_TABLE." WHERE categoryID<>0 ";
$result = array();
for ($i=0; $i<count($root); $i++)
{
$q = db_query("SELECT categoryID, name, products_count, parent FROM ".CATEGORIES_TABLE." WHERE categoryID<>0 and parent=".$root[$i][0]) or die (db_error());
while ($row = db_fetch_row($q))
$result[] = $row;
}
$smarty->assign("root_categories",$root);
$smarty->assign("root_categories_subs",$result);
$smarty->assign("main_content_template", "catalog.tpl.html");
}
?>Положите его в папку includes.
Создайте файл catalog.tpl.html с таким содержимым:
<table width=100% border=0 cellpadding=5>
{section name=i loop=$root_categories}
{if $smarty.section.i.index is div by 2}<tr>{/if}
<td width=1% align=center>
{if $root_categories[i][3] ne ""}<a href="index.php?categoryID={$root_categories[i][0]}"><img border=0 src="products_pictures/{$root_categories[i][3]}" alt="{$root_categories[i][1]}">{/if}
</td>
<td>
<a href="index.php?categoryID={$root_categories[i][0]}" class=cat>{$root_categories[i][1]}</a> <b>[{$root_categories[i][2]}]</b>:<br>
{* show sub categories *}
{assign var="tmp" value=0}
{section name=j loop=$root_categories_subs}
{if $root_categories_subs[j][3] == $root_categories[i][0]}
{if $tmp == 1}|
{else}
{assign var="tmp" value=1}
{/if}
<a href="index.php?categoryID={$root_categories_subs[j][0]}" class=standard>{$root_categories_subs[j][1]}</a>
{/if}
{/section}
</td>
</td>
{if ($smarty.section.i.index+1) is div by 2}</tr>{/if}
{/section}
</table>Положите его в папку с шаблонами, по умолчанию templates\tmpl1.
В нужном месте добавьте ссылку:
<a href="index.php?catalog=1">Каталог</a>
P.S.: Куски кода взяты со стандартного SSFree.
Неактивен