0

Using the pagination feature in stash something like this:

{exp:stash:get_list
    name="sv_blogs_post_list"
    parse_tags="yes"
    parse_conditionals="yes"
    process="end"
    prefix="st_pre"
    limit="{stash:list_limit}"
    paginate="bottom"
}

    {!-- THE PAGINATION --}
    {st_pre:paginate}
        {pagination_links}
            {previous_page}<a href="{pagination_url}" class="btn btn-brick flat">Previous Post</a>{/previous_page}
            {next_page}<a href="{pagination_url}" class="btn btn-brick flat pull-right">Next Post</a>{/next_page}
        {/pagination_links}
    {/st_pre:paginate}

{/exp:stash:get_list}

The problem is that the URL stays with the {url_title} of whatever the initial blog post read was. Is there a way to use the next and previous to actually link to the true link?


* UPDATE *

I decided to use the {exp:channel:next_entry} and {exp:channel:prev_entry} per a suggestion from @croxton. Now I have this:

{exp:channel:prev_entry
    url_title="{segment_2}"
    channel="blog_post"
}
    <a href='{path="blog"}' class='btn flat'>Previous Post</a>{/exp:channel:prev_entry}
{exp:channel:next_entry
    url_title="{segment_2}"
    channel="blog_post"
}
    <a href='{path="blog"}' class='btn flat pull-right'>Next Post</a>
{/exp:channel:next_entry}

NOW the issue is stash keeping the same variables on the page when it directs to the new link...

Current Page: http://my-site.com/blog/article-3

Previous Link: http://my-site.com/blog/article-2/

Next Link: http://my-site.com/blog/article-4

That is working great... However, the page content is keeping the stashed values for elements like <div class="title">{st_pre:sv_bp_title}</div>.

That sits inside my {exp:stash:get_list} which is set like this:

{exp:stash:get_list
    name="sv_blogs_post_list"
    parse_tags="yes"
    parse_conditionals="yes"
    process="end"
    prefix="st_pre"
    limit="{stash:list_limit}"
    paginate="bottom"
}

All of those are being set in a data template like this:

    {exp:stash:set_list name="sv_blogs_post_list" parse_tags="yes" parse_depth="2"}
        {exp:channel:entries
            channel="{stash:channel}"
            dynamic="{stash:dynamic}"
            orderby="{stash:order_by}"
            status="{stash:status}"
            limit="{stash:limit}"
            paginate="{stash:paginate}"
        }
            {stash:sv_bp_entry_id}{entry_id}{/stash:sv_bp_entry_id}
            {stash:sv_bp_entry_date}{entry_date format="%m.%d.%Y"}{/stash:sv_bp_entry_date}
            {stash:sv_bp_relative_time}{relative_date}{/stash:sv_bp_relative_time}
            {stash:sv_bp_author}{author}{/stash:sv_bp_author}
            {stash:sv_bp_screen_name}{screen_name}{/stash:sv_bp_screen_name}
            {stash:sv_bp_title}{title}{/stash:sv_bp_title}
            {stash:sv_bp_url_title}{url_title}{/stash:sv_bp_url_title}
            {stash:sv_bp_url_title_path}{url_title_path='blog'}{/stash:sv_bp_url_title_path}
            {stash:sv_bp_blog_copy}{blog_copy}{/stash:sv_bp_blog_copy}
            {exp:stash:set_list:nested name="sv_bp_header_images_{entry_id}" parse_tags="yes"}
                {header_image}
                    {stash:sv_bp_header_image}{image:url:slider}{/stash:sv_bp_header_image}
                    {stash:sv_bp_header_image_original}{image:url}{/stash:sv_bp_header_image_original}
                    {stash:sv_bp_header_image_title}{image:title}{/stash:sv_bp_header_image_title}
                {/header_image}
            {/exp:stash:set_list:nested}
        {/exp:channel:entries}
    {/exp:stash:set_list}

Am I missing a tag in my set or get for stash???

1 Answer 1

0

Thanks to Mark Croxton (Twitter) and Sam Royama (Skype) for the help with this one. Mark got me going with the Prev/Next entry solution. Sam helped me realize my rookie mistake of not accepting a url_title parameter in my set_list. GRRRRR

So... In the last block of code from the OP, I needed to add the url_title like this:

{exp:stash:set_list name="sv_blogs_post_list" parse_tags="yes" parse_depth="2"}
    {exp:channel:entries
        channel="{stash:channel}"
        dynamic="{stash:dynamic}"
        orderby="{stash:order_by}"
        status="{stash:status}"
        limit="{stash:limit}"
        paginate="{stash:paginate}"

        url_title="{stash:url_title}"

    }
        ...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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