Jump to content

Фильтры выпадающим списком


Recommended Posts

Переделываю фильтры из текстовых в выпадающий список.

Внешне выглядит как надо, но не работает правильно.

При выборе опции переходит перенаправление по адресу вида: http://адрес-сайта.ру/опция-фильтра

Где я допустил ошибку?

Код:

<!-- Фильтр по свойствам /-->
{if $properties}
<div id="dropdownfilter">
<table>
{foreach name=properties item=property from=$properties}
{assign var=property_id value=$property->property_id}
<tr>
<td>{$property->name}:</td>
<td>
<select onchange="document.location.href=this.options[this.selectedIndex].value">
{if $smarty.get.$property_id}
<option>
<a href='catalog/{$category->url}{$property->clear_url}'>все</a>
</option>
{else}<option checked>все</option>
{/if}
{foreach name=options from=$property->options item=option}
{if $smarty.get.$property_id == $option->value}
<option>{$option->value}</option>
{else}
<option><a href='catalog/{$category->url}{if $brand}/{$brand->url}{/if}{$option->url}'>{$option->value}</a></option>
{/if}
{/foreach}
</select>
</td>
</tr>
{/foreach}
</table>
</div>
{/if}
<!-- Фильтр по свойствам #End /-->

Link to post
Share on other sites

Kosjak76, спасибо за помощь!
Фильтр теперь работает как надо.

Конечный вид:

<!--Фильтр по свойствам /-->
{if $properties}
<div id="dropdownfilter">
<table>
{foreach name=properties item=property from=$properties}
{assign var=property_id value=$property->property_id}
<tr>
<td>{$property->name}:</td>
<td>
<select onchange="document.location.href=this.options[this.selectedIndex].value">
{if $smarty.get.$property_id}
<option value="catalog/{$category->url}{$property->clear_url}"><a href='catalog/{$category->url}{$property->clear_url}'>все</a></option>
{else}<option value="catalog/{$category->url}{$property->clear_url}">все</option>{/if}
{foreach name=options from=$property->options item=option}
{if $smarty.get.$property_id == $option->value}
<option selected>{$option->value}</option>
{else}
<option value="http://{$root_url}/catalog/{$category->url}{if $brand}/{$brand->url}{/if}{$option->url}">{$option->value}</option>
{/if}
{/foreach}
</select>
</td>
</tr>
{/foreach}
</table>
</div>
{/if}
<!-- Фильтр по свойствам #End /-->

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...