douqiangchuai7674
2015-09-23 15:32
浏览 36
已采纳

使用表达式引擎回显多个类别ID

I am building a page that will on page load list all entries in a specific channel just like any other page. The trick here is that the page will be filterable but with just JavaScript/Jquery allowing the user to filter without refreshing the page.

I am filtering by using data tags on the <li> elements and then manipulating the DOM based on which category/id was chosen. However, for some entries they have multiple selections within a category group and therefore the data tag ends up having only one id, whichever comes first in the category fields table.

My question here is, is it possible to echo multiple ids into a data tag using EE in its base form or will I need to find/create a custom plug-in in order to do this?

{exp:channel:entries channel="page-work-project" status="open"}
    <li {categories show_group="4"}data-category="{category_id "{/categories}>
        <a href="{url_title}">
            <div class="detail">
                <h4>{title}</h4>
            </div>
        </a>
    </li>
{/exp:channel:entries}

图片转代码服务由CSDN问答提供 功能建议

我正在构建一个页面,它将在页面加载列表中列出特定通道中的所有条目,就像任何其他页面一样。 这里的诀窍是页面将是可过滤的,但只有JavaScript / Jquery允许用户在不刷新页面的情况下进行过滤。

我使用&lt上的数据标签进行过滤 ; li&gt; 元素,然后根据选择的类别/ ID操纵DOM。 但是,对于某些条目,它们在类别组中有多个选择,因此数据标记最终只有一个ID,以类别字段表中的第一个为准。

我的问题是, 是否可以使用基本形式的EE将多个id回显到数据标记中,或者我是否需要查找/创建自定义插件才能执行此操作?

   {exp:channel:entries channel =“page-work-project”status =“open”} 
&lt; li {categories show_group =“4”} data-category =“{category_id”{/ categories}&gt; 
  &lt; a href =“{url_title}”&gt; 
&lt; div class =“detail”&gt; 
&lt; h4&gt; {title}&lt; / h4&gt; 
&lt; / div&gt; 
&lt; /  a&gt; 
&lt; / li&gt; 
 {/ exp:channel:entries} 
   
 
  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

  • douchen3562 2015-09-23 20:08
    最佳回答

    The issue here is that {categories show_group="4"}data-category="{category_id "{/categories} acts as for loop on it's own. So the code that it's rendering is actually <li data-category="id1" data-category="id2" data-category="id3">, which is not valid html.

    Instead you should put the {categories} tag within the data attribute like this:

    data-category="{categories show_group="4"} {category_id}- {/categories}"

    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题