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.

Include custom field within related entry?

July 14, 2007 11:46am

Subscribe [2]
  • #1 / Jul 14, 2007 11:46am

    textdriven

    107 posts

    I want to include a custom fields from the entry with the {related_entries} tag but it won’t render anything but the custom field name. Look at the field that says {en_caption}. That field belongs to the weblog entry and not the related entry but it seems it can’t be called.

    {exp:weblog:entries weblog="test"}
    
    <h3>{title}</h3>
    
    <p>{body}</p>
    
    <p>{related_entries id="images"}</p>
    
    <p>   <div class="gallery"><br />
       {thumb_url}<br />
       </div><br />
    {/related_entries}</p>
    
    <p>{/exp:weblog:entries}

  • #2 / Jul 14, 2007 3:03pm

    Derek Jones

    7561 posts

    The related entries tag pair is protected from the enclosing weblog entries tag.  If it were not, then {title} would also be parsed by the parent tag, along with any other weblog variables (and custom fields if they happened to share names).  You could use PHP on Output, though.  Note that without some additional protection, the {en_caption} field would have to have formatting set to “None” and could not contain double quotes.

    {exp:weblog:entries weblog="test"}
    
    <h3>{title}</h3>
    
    <p>{body}</p>
    
    <p><?php $en_caption = "{en_caption}"; ?></p>
    
    <p>{related_entries id="images"}</p>
    
    <p>   <div class="gallery"><br />
       {thumb_url}<br />
       </div><br />
    {/related_entries}</p>
    
    <p>{/exp:weblog:entries}

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

ExpressionEngine News!

#eecms, #events, #releases