thelia/choice-filter-module

允许通过模板和分类管理前端筛选器

安装数: 10,874

依赖项: 2

建议者: 0

安全性: 0

星标: 1

关注者: 6

分支: 2

开放性问题: 0

类型:thelia-module

2.1.1 2022-08-30 11:21 UTC

This package is auto-updated.

Last update: 2024-08-29 04:37:22 UTC


README

此模块允许通过模板和分类管理前端筛选器

安装

手动安装

  • 将模块复制到 <thelia_root>/local/modules/ 目录,并确保模块名称为 ChoiceFilter。
  • 在 Thelia 管理面板中激活它

Composer

将其添加到您的主 Thelia composer.json 文件中

composer require thelia/choice-filter-module:~2.0.0

用法

您可以选择筛选器的位置

  • 当您编辑模板时
  • 当您编辑分类时

循环

[choice_filter]

输入参数

输出参数

示例

对于模板

{loop name="choice_filter" type="choice_filter" template_id=$template_id}
    {if $TYPE == "feature" and $VISIBLE}
        {loop type="feature" name="feature-$ID" id=$ID}
            {* your code *}
        {/loop}
    {elseif $TYPE == "attribute" and $VISIBLE}
        {loop type="attribute" name="attribute-$ID" id=$ID}
            {* your code *}
        {/loop}
    {elseif $TYPE == "brand" and $VISIBLE}
        {* your code *}
    {elseif $TYPE == "price" and $VISIBLE}
        {* your code *}
    {/if}
{/loop}

对于分类

{loop name="choice_filter" type="choice_filter" category_id=$category_id}
    {if $TYPE == "feature" and $VISIBLE}
        {loop type="feature" name="feature-$ID" id=$ID}
            {* your code *}
        {/loop}
    {elseif $TYPE == "attribute" and $VISIBLE}
        {loop type="attribute" name="attribute-$ID" id=$ID}
            {* your code *}
        {/loop}
    {elseif $TYPE == "brand" and $VISIBLE}
        {* your code *}
    {elseif $TYPE == "price" and $VISIBLE}
        {* your code *}
    {/if}
{/loop}

为了性能,最好使用缓存块 http://doc.thelia.net/en/documentation/templates/smarty/cache.html

{cache key="choice-filter" ttl=600 category_id==$category_id}
    {loop name="choice_filter" type="choice_filter" category_id=$category_id}
        {if $TYPE == "feature" and $VISIBLE}
            {loop type="feature" name="feature-$ID" id=$ID}
                {* your code *}
            {/loop}
        {elseif $TYPE == "attribute" and $VISIBLE}
            {loop type="attribute" name="attribute-$ID" id=$ID}
                {* your code *}
            {/loop}
        {elseif $TYPE == "brand" and $VISIBLE}
            {* your code *}
        {elseif $TYPE == "price" and $VISIBLE}
            {* your code *}
        {/if}
    {/loop}
{/cache}