Twig 细枝中的If语句(用于Joomla中的粒子)

Twig 细枝中的If语句(用于Joomla中的粒子),twig,joomla3.0,Twig,Joomla3.0,尝试在Joomla中编辑一个粒子——我对twig是相当陌生的,我正在尝试根据垂直选项卡中的选择列出信息。我有一个点击刷新我的li编辑,使一个选项卡“选中”,并创建我的内部url: {% for item in particle.items %} <li> <a href="/Joomla/about-the-library/locations#{{ loop.index }}">{{ item.title|e }} <im

尝试在Joomla中编辑一个粒子——我对twig是相当陌生的,我正在尝试根据垂直选项卡中的选择列出信息。我有一个点击刷新我的li编辑,使一个选项卡“选中”,并创建我的内部url:

  {% for item in particle.items %}
    <li>
        <a href="/Joomla/about-the-library/locations#{{ loop.index }}">{{ item.title|e }}
        <img src="{{ url(item.image)|e }}" alt="{{ item.title|e }}">
        <div class="g-flexslider-carousel-item-image-preview-icon"></div>
        </a>
    </li>
  {% endfor %}
{%for particle.items%}
  • {%endfor%}
    这一切都很好,但我在尝试显示与所选项目关联的数据时遇到了一个问题。我试图创建一个变量来检查我的项目,但该变量似乎不是一个整数,我尝试了以下几点:

     {% set branch = app.request.pathinfo|trim('/Joomla/about-the-library/locations#') %}
              {% if loop.index == branch %}
                    <div class="g-flexslider-showcase-item-content-container">
                        <div class="g-flexslider-showcase-item-image">
                            <img src="{{ url(item.image)|e }}" alt="{{ item.title|e }}">
                        </div>  
    
    {%set branch=app.request.pathinfo | trim('/Joomla/about the library/locations#')%}
    {%if loop.index==branch%}
    
    谁能告诉我我做错了什么

    (我发现这很有帮助,但我不确定我是否正确使用了提供的答案。我也对答案进行了几个小时的筛选,但没有任何结果。)

    [2016年11月]-这仍然是本节的“我的”代码。这似乎只是if语句的一个问题,因为“else”语句(我正在使用它进行调试)不断出现

    {%for particle.items%}
    {%if-app.request.get('name')==item.URLname | e%}
    
    您已正确分支{{item.title | e}}

    问题在于
    url片段从来不会发送到服务器。使用
    querystring
    重写
    url会有伤害吗?谢谢@DarkBee,这就解释了这一点。我已转换为查询字符串解决方案,但我的if语句(
    {%if item.URLname==app.request.query.all%}
    )似乎仍然失败。我可能使用了错误的命令来提取查询字符串。仍在处理。看起来我的字符串返回为空。我尝试过:
    item.app.query.all
    item.app.query.get('name')
    ,甚至
    item.request.pathinfo
    。(我还尝试了几种排列,我觉得它们不应该返回任何东西。它们没有返回任何东西。)我想我遇到了一个比我想象的更复杂的问题。用新的aproach更新你的问题?供其
    app.request.get('name')
    ,不是
    item.app…..
    问题是
    url片段
    从未发送到服务器。使用
    querystring
    重写
    url会有伤害吗?谢谢@DarkBee,这就解释了这一点。我已转换为查询字符串解决方案,但我的if语句(
    {%if item.URLname==app.request.query.all%}
    )似乎仍然失败。我可能使用了错误的命令来提取查询字符串。仍在处理。看起来我的字符串返回为空。我尝试过:
    item.app.query.all
    item.app.query.get('name')
    ,甚至
    item.request.pathinfo
    。(我还尝试了几种排列,我觉得它们不应该返回任何东西。它们没有)我想我遇到了一个比我想象的更复杂的问题。用新的aproach更新你的问题?告诉我它的
    app.request.get('name')
    ,而不是
    item.app…