title: If statement in Twig (for Particle in Joomla)
body: <p>Trying to edit a particle in Joomla -- I'm fairly new to twig and I'm trying to list information based on a selection in vertical tabs. I have an on-click refresh for my li edit that makes a tab "selected" and creates my internal url: </p>
  
  <pre><code>  {% for item in particle.items %}
      &lt;li&gt;
          &lt;a href="/Joomla/about-the-library/locations#{{ loop.index }}"&gt;{{ item.title|e }}
          &lt;img src="{{ url(item.image)|e }}" alt="{{ item.title|e }}"&gt;
          &lt;div class="g-flexslider-carousel-item-image-preview-icon"&gt;&lt;/div&gt;
          &lt;/a&gt;
      &lt;/li&gt;
    {% endfor %}
  </code></pre>
  
  <p>This is all well and good, but I ran into an issue when trying to display the data associated with the selected item. I tried to create a variable to check my items against, but the variable doesn't seem to be coming back as an integer, and I've tried a few things: </p>
  
  <pre><code> {% set branch = app.request.pathinfo|trim('/Joomla/about-the-library/locations#') %}
            {% if loop.index == branch %}
                  &lt;div class="g-flexslider-showcase-item-content-container"&gt;
                      &lt;div class="g-flexslider-showcase-item-image"&gt;
                          &lt;img src="{{ url(item.image)|e }}" alt="{{ item.title|e }}"&gt;
                      &lt;/div&gt;  
  </code></pre>
  
  <p>Can anyone tell me what I'm doing incorrectly?</p>
  
  <p>(I found that <a href="https://stackoverflow.com/questions/9378714/get-current-url-in-twig-template/9384118#">get current url in twig template?</a> helped, but I'm not sure I'm using the answers provided correctly. I've also sifted through the <a href="http://twig.sensiolabs.org/documentation" rel="nofollow noreferrer">Twig Documentation</a> for a couple hours to no avail.)</p>
  
  <p>[Nov 2016] - This is still what "my" code looks like for this section. It seems to <em>just</em> be a problem with this if statement, as the "else" statement (which I'm using for debugging purposes) keeps coming through.</p>
  
  <p><code>{% for item in particle.items %} 
                  {% if  app.request.get('name') == item.URLname|e %}
                      &lt;p&gt;You have branched {{ item.title|e }} correctly. &lt;/p&gt;</code></p>