0

all - I'm trying to find a new way to return a single entry view and list view within a single template using stash and the only thing holding me up - and maybe I'm overlooking a simple solution - is the absence of a url_title parameter in the stash:get_list tag pair. Here's a bit more detail about what I'm trying to do:

In the main logic template, I have:

{embed="layouts/.inside"}

{exp:stash:set_list name="entries_loop" parse_tags="yes" save="yes" scope="site"}

{exp:low_reorder:entries set="apis" dynamic="no" disable="categories"}

    {stash:entry_title}{title}{/stash:entry_title}
    {stash:entry_url_title}{url_title}{/stash:entry_url_title}
    {stash:entry_icon}{cf_api_icon}{/stash:entry_icon}
    {stash:entry_short_description}{cf_api_short_description}{/stash:entry_short_description}

{/exp:low_reorder:entries}

{/exp:stash:set_list}

In the .inside layout template, I have:

{exp:ifelse parse="inward"} {if segment_2 == ""}

                    <h1>API Documentation</h1>

                    <p>Interdum et malesuada fames ac ante ipsum primis in faucibus. Proin convallis, arcu blandit iaculis sodales, orci purus imperdiet libero, nec vestibulum ligula nulla sit amet metus. Proin aliquam ante id sapien scelerisque lobortis. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Suspendisse eu mattis est, id vulputate erat. Proin suscipit venenatis tristique. Nam aliquet ullamcorper dolor, sed sodales augue varius non. Morbi nisl nisi, placerat ut malesuada eu, lobortis a nisl. Quisque non ultricies nulla. Proin mollis ut nisi at elementum. Aliquam nec lacus quis magna auctor feugiat vitae a velit. Morbi tempor risus non semper vehicula. Praesent mattis ligula nec mattis sollicitudin.</p>

<h3>Current APIs</h3>

    {exp:stash:get_list name="entries_loop"}
        {if count == "1"}<ul class="small-block-grid-2 medium-block-grid-3 large-block-grid-3 api-list">{/if}
        <li><a href="{path='{segment_1}/{entry_url_title}'}"><img src="{entry_icon}" alt="{entry_title}" /><h4>{entry_title}</h4></a>
        <p>{entry_short_description}</p>
        </li>
        {if count == total_results}</ul>{/if}
    {/exp:stash:get_list}

    {if:else}

    {exp:stash:get_list name="entries_loop" limit="1" dynamic="yes" url_title="{entry_url_title}"}

    <div class="row">
        <div class="large-3 small-3 columns">
            <img src="{entry_icon}" alt="{entry_title}" />
        </div>
        <div class="large-9 small-9 columns">
            <h1>{entry_title}</h1>
            {entry_short_description}
        </div>
    </div>

    <hr/>

    <p>Additional details here</p>

    <h3>Contents</h3>

    <ul class="side-nav">
        <li><a href="#">Item One</a></li>
        <li><a href="#">Item Two</a></li>
        <li><a href="#">Item Three</a></li>
        <li><a href="#">Item Four</a></li>
        <li><a href="#">Item Five</a></li>
    </ul>

    {/exp:stash:get_list}
{/if}
{/exp:ifelse}

So basically, what I was trying to do is stash the complete set of entries in the main template, then get that stashed list, conditionally showing all or one, depending on the url (yes, I will have to switch to switchee rather than ifelse add-on to accommodate pagination).

What I'm getting for a result right now is the same entry in either single entry view rather than the one I want. If the get_list loop has a parameter similar to url_title that I could point at a url segment, I'd be all set. Is there something similar that I can do? I was just trying to be as strategic as possible with the stashing of the content - rather than stash the complete list of entries and the single entry I want to see separately, I thought I could limit the get_list to a single entry in a way that would mirror how that could be done in an entries loop.

1

If your ifelse is handling segment3 then when you want to show single entry, could you use

{exp:stash:get_list name="entries" match="#^{segment_3}$#" against="entry_URL_title"}
...{snippet with layout}
    {/exp:stash:get_list}

Basically use the match function against the URL title. It has to be a regex. Have replied via phone so excuse the shortness of my reply.

| improve this answer | |

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.