1

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:

  {% 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 %}

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:

 {% 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>  

Can anyone tell me what I'm doing incorrectly?

(I found that get current url in twig template? helped, but I'm not sure I'm using the answers provided correctly. I've also sifted through the Twig Documentation for a couple hours to no avail.)

[Nov 2016] - This is still what "my" code looks like for this section. It seems to just be a problem with this if statement, as the "else" statement (which I'm using for debugging purposes) keeps coming through.

{% for item in particle.items %} {% if app.request.get('name') == item.URLname|e %} <p>You have branched {{ item.title|e }} correctly. </p>

Community
  • 1
  • 1
Aaron
  • 11
  • 3
  • The problem is that `url fragments` are never sent towards the server. Would it hurt to use the `querystring` or `rewriting` the url? – DarkBee May 11 '16 at 20:33
  • Thanks @DarkBee, that explains that. I've converted to a query string solution, but my if statement ( `{% if item.URLname == app.request.query.all %}` ) still seems to be failing. I may be using the wrong command to pull my query string. Still working on that. – Aaron May 12 '16 at 19:38
  • It looks like my strings are returning empty. I've tried: `item.app.query.all `, `item.app.query.get('name')`, and even `item.request.pathinfo`. (I've also tried several permutations that I didn't feel should return anything. They didn't.) I think I'm having a more intricate issue than I had supposed. – Aaron May 12 '16 at 20:43
  • Update your question with the new aproach? – DarkBee May 12 '16 at 20:53
  • fyi its `app.request.get('name')`, not `item.app.....` – DarkBee May 12 '16 at 21:06
  • Thanks @DarkBee. Coming full circle 6 months later, I'm back to this problem. It's now one small floating change I'd like to make on this template. I still haven't had to use twig for anything else, but I've been trying to read up on this. I keep wondering if maybe I'm having an issue with the container -- I wish I could debug web dev easier than trial and error. My for loop and if are listed above as they stand now. – Aaron Nov 08 '16 at 00:43

0 Answers0