ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Next / Previous Entry with channel fields

January 21, 2014 11:50pm

Subscribe [2]
  • #1 / Jan 21, 2014 11:50pm

    sub_stance

    35 posts

    Hi everyone,

    im working on a blog that has single entries which need to link between ‘next/previous’ entries. I’ve successfully used the channel next_entry & previous_entry tags, but the problem im having is trying to show the custom channel fields for those entries (in my case ‘{sub_title}’ and also the entry dates for those entries.

    I couldn’t find any parameters that will help me pull the specific channel field of the entries:
    http://ellislab.com/expressionengine/user-guide/modules/channel/entry_linking.html


    I’ve been trying to fiddle with using channel tags and the orderby & sort tags without luck

    {exp:channel:prev_entry channel="restaurant_reviews" status="open"}
    <div class="footer-back"><a href="http://{path=food/review}">BACK</a></div>
    
    <div class="footer-left">
     <strong>{title}</strong> {sub_title}
     <a href="http://{path=food/review}">view post</a> | {entry_date format="%m-%d-%Y"} | {total_results} Comments
    </div><!-- end .footer-left -->
    {/exp:channel:prev_entry}
    
    
    {exp:channel:next_entry channel="restaurant_reviews" status="open"}
    <div class="footer-nextpost"><a href="http://{path=food/review}">NEXT POST</a></div>
    <div class="footer-right">
     <strong>{title}</strong>  {sub_title}
     <a href="http://{path=food/review}">view post</a> | {entry_date format="%m-%d-%Y"} | 3 Comments
    </div><!-- end .footer-right -->
    {/exp:channel:next_entry}

    please let me know if there is a workaround that i haven’t been able to find or code that Im missing out on

    Thanks!

  • #2 / Jan 22, 2014 10:47am

    Boyink!

    5011 posts

    This might be a case where you’ll have to use an embedded template that contains a channel:entries tag and pass the entry_id through from the (exp:channel:next_entry loop) as an embed variable.

    Your embedded template will then actually be displaying your custom fields/date.

  • #3 / Mar 23, 2014 7:56pm

    sub_stance

    35 posts

    thanks for the reply Boyink!

    are you talking about using the pagination code and using if statements for prev/next page?

    Im a bit confused as what you mean, how would i use the entry_id as an embed variable?

  • #4 / Mar 24, 2014 7:58am

    Boyink!

    5011 posts

    Holy delayed response Batman! 😊

    The basic approach would be:

    {exp:channel:next_entry}
        Next entry: <a href="http://{path=site/comments}">{title}</a>
    {embed="embeds/gimme_custom_fields" my_entry_id='{entry_id}'}
    {/exp:channel:next_entry}

    Then in the embedded ‘gimme_custom_fields’ template:

    {exp:channel:entries channel="whatever' entry_id='{embed:my_entry_id}'}
      {custom_field}
    {/exp:channel:entries}

     

  • #5 / Mar 30, 2014 4:38pm

    sub_stance

    35 posts

    Thanks Robin!

    I have the ‘embed/gimme_custom_fields’ showing the custom field, but the {embed} is not pulling the custom field from ‘embed/gimme_custom_fields’

    Here’s my code:

    next/previous post:

    {exp:channel:next_entry channel="inthecity" status="open"}
    {embed="embed/subtitle_custom_field" my_entry_id='{entry_id}'}
    {/exp:channel:next_entry}

     

    “embed/subtitle_custom_fields”

    {exp:channel:entries channel="inthecity' entry_id='{embed:my_entry_id}'}
      {sub_title}
    {/exp:channel:entries}

    Is there something im missing?

    Thanks again!
    -Dark Knight

  • #6 / Mar 31, 2014 8:17am

    Boyink!

    5011 posts

    Try adding ‘dynamic=“no” to the channel entries loop in the embedded template.

  • #7 / Apr 03, 2014 4:29pm

    sub_stance

    35 posts

    Which channel entries loop are you referring to?

    I added it to the channel:next_entry loop with no results:

    next/previous post:

    {exp:channel:next_entry channel="inthecity" status="open" dynamic="no"}
    {embed="embed/subtitle_custom_field" my_entry_id='{entry_id}'}
    {/exp:channel:next_entry}

     

    “embed/subtitle_custom_fields”

    {exp:channel:entries channel="inthecity' entry_id='{embed:my_entry_id}'}
      {sub_title}
    {/exp:channel:entries}

     

  • #8 / Apr 03, 2014 4:30pm

    Boyink!

    5011 posts

    What happened when you tried the other one? 😉

  • #9 / Apr 03, 2014 4:36pm

    sub_stance

    35 posts

    still no luck :(

    i also tried adding ’ related_categories_mode=“yes” custom_fields=“yes”  ’ to the code, shooting in the dark

  • #10 / Apr 03, 2014 4:37pm

    Boyink!

    5011 posts

    Have you confirmed the embed variable is passing through ok?

  • #11 / Apr 03, 2014 4:44pm

    sub_stance

    35 posts

    Yes, when i use:

    {embed="embed/subtitle_custom_field"}

    it pulls each of the custom field data loop

    Only when i add in my_entry_id=’{entry_id}’ it doesn’t pull anymore

  • #12 / Apr 03, 2014 4:44pm

    Boyink!

    5011 posts

    The basic debug process here:

    - Eliminate the embed variable
    - Hard-code a known good entry ID into the second loop.
    - Get content returned.
    - Put the embed variable back in place
    - Display the embed variable visually in the second loop - so you can see what value it has.
    - Then put the embed variable in place as a parameter.


    Have dynamic==“no” in the second loop, and get rid of those other parameters. Just channel, entry_id, and dynamic=“no”.

  • #13 / Apr 03, 2014 5:45pm

    sub_stance

    35 posts

    First debug process didn’t work:

    {exp:channel:next_entry channel="restaurant_reviews" status="open"}
    {embed="embed/subtitle_custom_field"}
    {/exp:channel:next_entry}

    embed:

    {exp:channel:entries channel="restaurant_reviews' entry_id='18' dynamic="no"}
    {sub_title}
    {/exp:channel:entries}

    and entry_id 18 has a {sub_title} field

    should i not be using ‘next_entry’ as the channel entry loop?

  • #14 / Apr 03, 2014 5:47pm

    sub_stance

    35 posts

    even when just loading up the embed page itself it’s not pulling the {sub_title} since i put in the entry_id=“18”

  • #15 / Apr 03, 2014 5:50pm

    sub_stance

    35 posts

    okay i got it working when i took out ’ dynamic=“no” ’ from the embed loop, going to try debugging again

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases