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.

related entries visibility control

August 03, 2011 11:16am

Subscribe [3]
  • #1 / Aug 03, 2011 11:16am

    moonbeetle

    81 posts

    This question may be related to a resolved thread.

    (at least what the title of that thread is concerned)

    Please correct me if I’m wrong but it looks like displaying related entries is an on/off thing. If you have related entries, they will show up regardless of their status (e.g. Closed) and regardless of their Expiry Date, right? Would like to get more info on how I can have more control over the visibility of related entries, especially in an automated scenario like setting and checking on an expiry date.

    Partly found the answer here and agree this would be a great feature request if avoiding an extra embed would be beneficial.

  • #2 / Aug 04, 2011 2:01am

    John Henry Donovan

    12339 posts

    Hi Joris,

    With the status you can just add a conditional like so to check your status

    {related_entries id="your_field"}
    
    {if status == "open"}
     <h2>{title}</h2>
    <p>{/if}</p>
    
    <p>{/related_entries}

    Again with expired entries. A conditional to show them again

    {related_entries id="your_field"}
    
    {if "{current_time format='%U'}" > "{expiration_date format='%U'}"}
     <h2>{title}</h2>
    <p>{/if}</p>
    
    <p>{/related_entries}

    Does that help?

  • #3 / Aug 04, 2011 4:27am

    moonbeetle

    81 posts

    Thanks John, very helpful information would also be a great addition to the User Guide docs on related entries.
    The first code sample works. For the second I needed a small change:

    {related_entries id="your_related_entries_field"}
    {if "{expiration_date}" == FALSE || "{current_time format='%U'}" < "{expiration_date format='%U'}"}
    <h2>{title}</h2>
    <p>{/if}<br />
    {/related_entries}

    Added a check if the expiration_date of the related entry is set (not set = no expiration, thus show)
    Changed the > operator in <.

  • #4 / Aug 04, 2011 6:17pm

    Dan Decker

    7338 posts

    Hi moonbeetle,

    Thanks for sharing your additions and suggestions! It looks like you are all good otherwise, so I’m closing this out. Feel free to start a new thread if you need assistance in the future 😊

    Cheers!

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

ExpressionEngine News!

#eecms, #events, #releases