Бонус: при переходе в прайс-лист из категории сразу откроется прайс-лист этой категории.
1. в файле pricelist.php
1.1 строку
" where parent=".(int)$parent." order by sort_order, name");
заменяем на
# BEGIN select-pricelist-category
#" where parent=".(int)$parent." order by sort_order, name");
" where ".($level==0 && $parent>1?"categoryID":"parent")."=$parent order by sort_order, name");
# END select-pricelist-category
1.2 строки
$sort_string = str_replace( "{ASC_NAME}",
"<a href='".$urlToSort."&sort=name&direction=ASC'>".STRING_ASC."</a>", $sort_string );
$sort_string = str_replace( "{DESC_NAME}",
"<a href='".$urlToSort."&sort=name&direction=DESC'>".STRING_DESC."</a>", $sort_string );
$sort_string = str_replace( "{ASC_PRICE}",
"<a href='".$urlToSort."&sort=Price&direction=ASC'>".STRING_ASC."</a>", $sort_string );
$sort_string = str_replace( "{DESC_PRICE}",
"<a href='".$urlToSort."&sort=Price&direction=DESC'>".STRING_DESC."</a>", $sort_string );
заменяем на
# BEGIN select-pricelist-category
/*
$sort_string = str_replace( "{ASC_NAME}",
"<a href='".$urlToSort."&sort=name&direction=ASC'>".STRING_ASC."</a>", $sort_string );
$sort_string = str_replace( "{DESC_NAME}",
"<a href='".$urlToSort."&sort=name&direction=DESC'>".STRING_DESC."</a>", $sort_string );
$sort_string = str_replace( "{ASC_PRICE}",
"<a href='".$urlToSort."&sort=Price&direction=ASC'>".STRING_ASC."</a>", $sort_string );
$sort_string = str_replace( "{DESC_PRICE}",
"<a href='".$urlToSort."&sort=Price&direction=DESC'>".STRING_DESC."</a>", $sort_string );
*/
$sort_string = str_replace( "{ASC_NAME}",
"<a href='".$urlToSort."&sort=name&direction=ASC".((isset($_REQUEST['category_select']) && $_REQUEST['category_select'] > 0)?"&category_select=".$_REQUEST['category_select']:"")."'>".STRING_ASC."</a>", $sort_string );
$sort_string = str_replace( "{DESC_NAME}",
"<a href='".$urlToSort."&sort=name&direction=DESC".((isset($_REQUEST['category_select']) && $_REQUEST['category_select'] > 0)?"&category_select=".$_REQUEST['category_select']:"")."'>".STRING_DESC."</a>", $sort_string );
$sort_string = str_replace( "{ASC_PRICE}",
"<a href='".$urlToSort."&sort=Price&direction=ASC".((isset($_REQUEST['category_select']) && $_REQUEST['category_select'] > 0)?"&category_select=".$_REQUEST['category_select']:"")."'>".STRING_ASC."</a>", $sort_string );
$sort_string = str_replace( "{DESC_PRICE}",
"<a href='".$urlToSort."&sort=Price&direction=DESC".((isset($_REQUEST['category_select']) && $_REQUEST['category_select'] > 0)?"&category_select=".$_REQUEST['category_select']:"")."'>".STRING_DESC."</a>", $sort_string );
# END select-pricelist-category
1.3 строки
$pricelist_elements = pricessCategories(1, 0);
$smarty->assign("pricelist_elements", $pricelist_elements);
заменяем на
# BEGIN select-pricelist-category
#$pricelist_elements = pricessCategories(1, 0);
#$smarty->assign("pricelist_elements", $pricelist_elements);
$pricelist_elements = pricessCategories((isset($_REQUEST['category_select']) && $_REQUEST['category_select'] > 0)?$_REQUEST['category_select']:1, 0);
$smarty->assign("category_select", $cats );
if (isset($_REQUEST['category_select']) && $_REQUEST['category_select'] > 0)
{
$smarty->assign("selected_category", $_REQUEST['category_select']);
$smarty->assign("pricelist_elements", $pricelist_elements);
}
# END select-pricelist-category
2. в файле pricelist.tpl.html после строки
{include file="header.tpl.html" header="`$smarty.const.STRING_PRICELIST` `$smarty.const.CONF_SHOP_NAME`"}
вставляем
{* BEGIN select-pricelist-category *}
{if $category_select}
<form action="price.html" id="pricelist" method="post">
<select name="category_select" onchange="document.getElementById('pricelist').submit();return false;">
{if !$selected_category}<option value="0">Выберите категорию</option>{/if}
<option value="1"{if $selected_category == 1} selected{/if}>Все категории</option>
{foreach from=$category_select item=cat}
<option value="{$cat.categoryID}"{if $selected_category == $cat.categoryID} selected{/if}>{section name=level loop=$cat.level} {/section}{$cat.name}</option>
{/foreach}
</select>
</form>
{/if}
{* END select-pricelist-category *}
3. в файле index.tpl.html строку
<span class="delm">|</span><a href="{if $smarty.const.CONF_MOD_REWRITE eq 1}price.html{else}index.php?show_price=yes{/if}">Прайс-лист</a>
заменяем на
{* BEGIN select-pricelist-category *}
{*<span class="delm">|</span><a href="{if $smarty.const.CONF_MOD_REWRITE eq 1}price.html{else}index.php?show_price=yes{/if}">Прайс-лист</a>*}
<span class="delm">|</span><a href="{if $categoryID > 1}index.php?show_price=yes&category_select={$categoryID}{else}{if $smarty.const.CONF_MOD_REWRITE eq 1}price.html{else}index.php?show_price=yes{/if}{/if}">Прайс-лист</a>
{* END select-pricelist-category *}