我有以下问题。在电子商务网站上(使用 Prestashop 制作,因此使用 Smarty),产品分类不起作用。这是一个 SELECT 字段,当用户选择某个选项(站点重新加载)时会动态更改。请看下面的代码:
首先,聪明的:
{if isset($orderby) AND isset($orderway)}
<!-- Sort products -->
{if isset($smarty.get.id_category) && $smarty.get.id_category}
{assign var='request' value=$link->getPaginationLink('category', $category, false, true)}
{elseif isset($smarty.get.id_manufacturer) && $smarty.get.id_manufacturer}
{assign var='request' value=$link->getPaginationLink('manufacturer', $manufacturer, false, true)}
{elseif isset($smarty.get.id_supplier) && $smarty.get.id_supplier}
{assign var='request' value=$link->getPaginationLink('supplier', $supplier, false, true)}
{else}
{assign var='request' value=$link->getPaginationLink(false, false, false, true)}
{/if}
然后,jQuery:
<script type="text/javascript">
//<![CDATA[
{literal}
$(document).ready(function()
{
$('#selectPrductSort').change(function()
{
var requestSortProducts = '{/literal}{$request}{literal}';
var splitData = $(this).val().split(':');
document.location.href = requestSortProducts + ((requestSortProducts.indexOf('?') < 0) ? '?' : '&') + 'orderby=' + splitData[0] + '&orderway=' + splitData[1];
});
});
//]]>
{/literal}
</script>
和 HTML:
<form id="productsSortForm" action="{$request|escape:'htmlall':'UTF-8'}">
<p class="select">
<label for="selectPrductSort">{l s='Sortuj wg'} </label>
<select id="selectPrductSort">
<option value="{$orderbydefault|escape:'htmlall':'UTF-8'}:{$orderwaydefault|escape:'htmlall':'UTF-8'}" {if $orderby eq $orderbydefault}selected="selected"{/if}>{l s='--'}</option>
{if !$PS_CATALOG_MODE}
<option value="price:asc" {if $orderby eq 'price' AND $orderway eq 'asc'}selected="selected"{/if}>{l s='ceny - od najniższej'}</option>
<option value="price:desc" {if $orderby eq 'price' AND $orderway eq 'desc'}selected="selected"{/if}>{l s='ceny - od najwyższej'}</option>
{/if}
<option value="name:asc" {if $orderby eq 'name' AND $orderway eq 'asc'}selected="selected"{/if}>{l s='nazwy produktu - od A do Z'}</option>
<option value="name:desc" {if $orderby eq 'name' AND $orderway eq 'desc'}selected="selected"{/if}>{l s='nazwy produktu - od Z do A'}</option>
{if !$PS_CATALOG_MODE}
<option value="quantity:desc" {if $orderby eq 'quantity' AND $orderway eq 'desc'}selected="selected"{/if}>{l s='dostępności'}</option>
{/if}
</select>
</p>
</form>
在此链接下 - http://skleppatrioty.pl/category.php?id_category=5 - 您可以看到一个工作示例。它是一个 SELECT 字段,紧挨着文本“Sortuj wg”,位于主右侧列的上部。
我错过了什么吗?感谢您的帮助。