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.

Embedding and custom field data.

January 05, 2012 3:15pm

Subscribe [2]
  • #1 / Jan 05, 2012 3:15pm

    Charming Nerd

    196 posts

    I forgot how to embed a file and still have the custom field variables work for that entry. I know it is because of the parsing order, buy can someone remind me? Here is a simplified example:

    {exp:channel:entries channel="trips" limit="1"}
    
      <div id="contentarea">
      
    
         {embed="includes/sidebar"}
    
       </div>
      <!-- /content -->
        
    {/exp:channel:entries}


    Inside sidebar I would have calls to fields, like so:

    <h1>{title}</h1>
    <h2>{trip_type}</h2>

     

     

  • #2 / Jan 06, 2012 6:41am

    John St-Amand

    865 posts

    Simple enough:

    {embed="includes/sidebar" the_title="{title}” the_trip_type=”{trip_type}”}

    Then in the sidebar template:

    <h1>{embed:the_title}</h1>

    {embed:the_trip_type}

    You can do the same thing for any custom field or value you want to “declare” in one template in the embed tag to pass into the embedded template for use within the embedded template.

    Cheers,
    John

  • #3 / Jan 06, 2012 1:53pm

    Charming Nerd

    196 posts

    That isn’t an elegant solution. I simplified the example but in reality there are many custom fields that would need to get passed in that way. I just ended up using the channel tag pair in the embed. I thought there could be a way to avoid having to put the tag pair in multiple locations.

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

ExpressionEngine News!

#eecms, #events, #releases