0

The following code works if I comment out the Matrix fields (images {stash:st_{pre_channel}_image_url}).

However, I can't get the code working with the image tags back in. I'm guessing it's a parse order issues :-/

I've tried everything I can think of, but no joy. Could someone point me in the right direction please?

  {preload_replace:pre_channel="people"}

    {exp:channel:entries disable="" channel="{pre_channel}" dynamic="no"}
    {categories}
        {exp:stash:append_list name="{pre_channel}_{category_id}" parse_tags="yes"}

        {!-- Main  --}
        {stash:st_{pre_channel}_title}{title}{/stash:st_{pre_channel}_title}
        {stash:st_{pre_channel}_page_url}{page_url}{/stash:st_{pre_channel}_page_url}

        {!-- Content --}
        {stash:st_{pre_channel}_intro}{cf_{pre_channel}_intro}{/stash:st_{pre_channel}_intro}
        {stash:st_{pre_channel}_maincontent}{cf_{pre_channel}_maincontent}{/stash:st_{pre_channel}_maincontent}

        {!-- Page Specific --}
        {stash:st_{pre_channel}_location}{cf_{pre_channel}_location}{/stash:st_{pre_channel}_location}

        {!-- Image --}
        {stash:st_{pre_channel}_image_url}
            {cf_{pre_channel}_images limit="1"}
                {mx_image}
            {/cf_{pre_channel}_images}
        {/stash:st_{pre_channel}_image_url}

        {stash:st_{pre_channel}_image_caption}    {cf_{pre_channel}_images limit="1"}{mx_caption}{/cf_{pre_channel}_images}{/stash:st_{pre_channel}_image_caption}

    {/exp:stash:append_list}
    {/categories}
{/exp:channel:entries}

Get

    {exp:channel:categories channel="{pre_channel}" style="linear" show_empty="no"}
        <div class="span12">
        <h3>{category_name}</h3>
        <div class="row">
            {exp:stash:get_list name="{pre_channel}_{category_id}"}
                <article class="span4">
                    <a href="{st_{pre_channel}_page_url}">
                        <img src="{st_people_image_url}" alt="{st_{pre_channel}_title}">
                    </a>
                    <header>
                        <a href="{st_{pre_channel}_page_url}"><h2>{st_{pre_channel}_title}</h2></a>
                        <p class="meta">{st_{pre_channel}_location}</p>
                    </header>
                </article>
            {/exp:stash:get_list}
        </div>
    </div>
{/exp:channel:categories}
1

Why is the matrix inside {categories} variable pair? Looks like the point is that.

Matrix tag pairs won't get parsed if they are inside the categories tag pair.

I tried to find a way to do what you need, but I couldn't find any solution without using multiple channel:entries, on one way or another. Even using addons, we can't scape of this. Per example, there are some plugins that group entries by its categories, as Category Sorted Entries and NSM Categories, but they don't allow you the get data from matrix fields, which means: multiple channel:entries variable pairs!

So, lets try to do this without addons.

{preload_replace:pre_channel="people"}
{exp:channel:categories channel="{pre_channel}" style="linear" show_empty="no" parse="inward"}
    <div class="span12">
    <h3>{category_name}</h3>
    <div class="row">
        {exp:channel:entries disable="" channel="{pre_channel}" dynamic="no" category="{category_id}"}
            <article class="span4">
                <a href="{page_url}">
                    <img src="{cf_{pre_channel}_images limit='1'}{mx_image}{/cf_{pre_channel}_images}" alt="{title}">
                </a>
                <header>
                    <a href="{page_url}"><h2>{title}</h2></a>
                    <p class="meta">{cf_{pre_channel}_location}</p>
                </header>
            </article>
        {/exp:channel:entries}
    </div>
</div>
{/exp:channel:categories}

By this way, the channel:categories variable pair will created one channel:entries variable pair for every category. Entries could repeat if they have more than one category on this group.

Sadly, this is a really heavy code to parse. You should enable some cache feature on the tags or on the page.

| improve this answer | |
  • The Matrix loops through a set of images. Surely it needs to be inside the {categories} tags to be associated to the exp:stash:get_list? – Matt Ellis Jun 5 '13 at 7:35
  • 1
    Matrix tag pairs won't get parsed if they are inside the categories tag pair. I'm not sure I understand why you need a unique stash list for each category? Isn't the list data you are capturing the same regardless of category? – Mark Croxton Jun 5 '13 at 10:30
  • Yes, the list data is the same, but I'm grouping the entries by category. Is this not the way to go? I started off using this example - devot-ee.com/add-ons/support/stash/viewthread/7518#25397 – Matt Ellis Jun 5 '13 at 15:27
  • @MatthewEllis, I see. I gonna take a better look and return to you. – Robson Sobral Jun 5 '13 at 18:14
  • Thanks Robson, I think that's set me in the right direction... will have a play and get back to you! :) – Matt Ellis Jun 6 '13 at 11:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.