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.

How do I use an {embed} within an {exp:weblog:entries} tag?

June 27, 2008 10:51pm

Subscribe [3]
  • #1 / Jun 27, 2008 10:51pm

    tehulong

    18 posts

    Is it possible to use an {embed} that has custom weblog entry tags within an {exp:weblog:entries} tag?

    When I use the embed, the embedded tags are not parsed.  For example:

    Main Template:

    {exp:weblog:entries weblog="something"}
    
    {embed="embedded/misc"}
    
    {/exp:weblog:entries}

    Embedded Template:

    {weblog_title}

    Instead of the parsed custom field weblog title showing up, the page actually displays {weblog_title}.

    Is there a way to get around this?

  • #2 / Jun 28, 2008 1:02am

    soxhead

    69 posts

    The embed template is going to need its own set of {exp:weblog:entries} tags.

    What you can do is pass the entry id of a given entry to the embed template so that you can embed the /misc template for each entry.

    So you’d do something like this in your “main” template:

    {exp:weblog:entries weblog="something"}

    {embed="embedded/misc" this_post={entry_id}}

    {/exp:weblog:entries}

    And then in the embed template:

    {exp:weblog:entries entry_id=this_post}
    {weblog_title}
    {/exp:weblog:entries}

    Hope that helps.

  • #3 / Jun 28, 2008 1:41am

    AJP

    311 posts

    Inside the embed, it’s probably a good idea to use the dynamic=“off” parameter as well.
    Also, you need to prefix all embed parameters with “embed:” and then the variable name.
    {embed:this_post}

    <pre><code>

    EMBED
    {exp:weblog:entries weblog="name" dynamic="off" entry_id="{embed:this_post}” limit=“1”}
    {title}
    {/exp:weblog:entries}

  • #4 / Jun 28, 2008 3:04am

    tehulong

    18 posts

    Hmm, I’ve tried out the above code but it doesn’t seem to be working.  I’m getting blank stuff where the embed should be.

    Here’s my code now:

    Main Template

    {exp:weblog:entries weblog="something" category="1" limit="10" offset="1" paginate="bottom"}
    
    {embed="embedded/misc" this_post={entry_id}}
    
    {/exp:weblog:entries}

    embedded/misc

    {exp:weblog:entries weblog="something" dynamic="off" entry_id="{embed:this_post}" limit="1"}
    
    {content}
    
    {/exp:weblog:entries}

    Am I doing something wrong?

  • #5 / Jun 28, 2008 3:24am

    tehulong

    18 posts

    Ah ok, I figured it out guys—the code was missing quotation marks around the variable to be passed.

    Thanks for the help!  Here’s the stuff that works:

    Main Template

    {exp:weblog:entries weblog="something" category="1" limit="10" offset="1" paginate="bottom"}
    
    {embed="embedded/misc" this_post="{entry_id}"}
    
    {/exp:weblog:entries}

    embedded/misc

    {exp:weblog:entries weblog="something" dynamic="off" entry_id="{embed:this_post}" limit="1"}
    
    {content}
    
    {/exp:weblog:entries}
  • #6 / Jun 28, 2008 4:00pm

    soxhead

    69 posts

    AJP,
    Thanks for the corrections. That will teach me to post while intoxicated.

    Actually, it won’t. But it’s a nice thought.

    lobstersan,
    Glad you got it working.

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

ExpressionEngine News!

#eecms, #events, #releases