1

I have an artists page where i want to show next/prev from that artist How to do that in Expression Engine? Also: The artist is a child of a parent, and i only want the child(artist id) not parent category id. The {exp:channel:next_entry/prev_entry} tag is outside of my {exp:channel:entries} tag

This works:

                {exp:channel:next_entry category="12" }
                     <a href="{path='portfolio/project'}">Next Project</a>
                {/exp:channel:next_entry}

                {exp:channel:prev_entry category="12" }
                     <a href="{path='portfolio/project'}">Previous Project</a>
                {/exp:channel:prev_entry}

And this gives 12 as result because of some previous coding:

                  <? echo $artistid ?>

So i thought this would work:

                {exp:channel:next_entry category="<?php echo $artistid ?>" }
                       <a href="{path='portfolio/project'}">Next Project</a>
                {/exp:channel:next_entry}

                {exp:channel:prev_entry category="<?php echo $artistid ?>" }
                     <a href="{path='portfolio/project'}">Previous Project</a>
                {/exp:channel:prev_entry}

Why doesn't it work?

1 Answer 1

1

Looks like a parse order issue: http://loweblog.com/downloads/ee-parse-order.pdf

You can use an embed or probably also Stash. I can't tell you how with Stash but here's how with an embed:


In main template, change the next/previous code to:

{embed="includes/prevnext" id="<?php echo $artistid ?>"}

* update "includes/prevnext" to your actual template name.


Then in the "includes/prevnext" template, use:

 {exp:channel:next_entry category="{embed:id}" }
   <a href="{path='portfolio/project'}">Next Project</a>
 {/exp:channel:next_entry}

 {exp:channel:prev_entry category="{embed:id}" }
   <a href="{path='portfolio/project'}">Previous Project</a>
 {/exp:channel:prev_entry}
1
  • perfect! for some reason i was thinking the embed wouldn't know the current entry id, but it does Commented Nov 28, 2013 at 9:23

Your Answer

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

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