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.

Latest entries box, exclude current entry.

January 13, 2009 2:15pm

Subscribe [3]
  • #1 / Jan 13, 2009 2:15pm

    wspub

    21 posts

    Im trying to do something that should be quite simple.

    At the bottom of my individual entry template, I have an embedded template. This template lists the 5 latest entries. I want it to exclude the current entry being viewed, but have not been able to do so.

    I have tried passing along the entry_id to exclude:

    {embed="boxes/latest-headlines" exclude={entry_id}}

    No dice. I’ve also tried using the query module to no avail.

    Any ideas as to how this might be accomplished?

    Thanks

  • #2 / Jan 13, 2009 2:31pm

    Pascal Kriete

    2589 posts

    You need quotes around your embed variable:

    {embed="site/export" the_id="{entry_id}"}

    And then something like this for your other template:

    {exp:weblog:entries weblog="weblog" entry_id="not {embed:the_id}" orderby="date"  limit="5" dynamic="off"}

    Does that help?

  • #3 / Jan 13, 2009 5:48pm

    wspub

    21 posts

    Thanks for the reply, but that does not seem to work. Instead of the numeric entry_id being passed to the sub template, it passes the actual word “entry_id”. I verified this by using “{embed: exclude}” in my template. The output was “entry_id”.

  • #4 / Jan 13, 2009 6:21pm

    Ingmar

    29245 posts

    Can you show us some more of your code? Also, what version and build of EE are you on?

  • #5 / Jan 16, 2009 1:25pm

    wspub

    21 posts

    Can you show us some more of your code? Also, what version and build of EE are you on?

    I’m not sure what how much more of the code is applicable, but I’ll try. I’m running 1.6.5. Also tried it on a dev server running 1.6.6. Same problem.

    I have a template to display a single entry.

    {exp:weblog:entries require_entry="yes" weblog="blogname" orderby="date" sort="desc" dynamic="on" limit="1" show_pages="no"}
    Entry Data Here
    {/exp:weblog:entries}

    Below the entry data I have a box to display the 5 latest entries. I do not want to display the current entry.

    {embed="boxes/latest-headlines" exclude="{entry_id}"}

    Here is the code for the “Latest Headlines”

    <div id="latest_headlines">
    <h2>Latest Headlines</h2>
    <p><ul><br />
    {exp:weblog:entries weblog="blogname" entry_id="not {embed:exclude}" orderby="date"  limit="5" dynamic="off" sort="desc"} <br />
            <li><a href="http://{path=/entry/{url_title}">{title}</a></li><br />
            </ul><br />
    </div>

    I think that gives a good indication of what I’m trying to do. It seems EE has a hard time passing along template variables to embedded templates.

  • #6 / Jan 16, 2009 2:02pm

    Pascal Kriete

    2589 posts

    Is the embed inside the weblog entries tag?

    {exp:weblog:entries require_entry="yes" weblog="blogname" orderby="date" sort="desc" dynamic="on" limit="1" show_pages="no"}
    Entry Data Here
    {embed="boxes/latest-headlines" exclude="{entry_id}"}
    {/exp:weblog:entries}
  • #7 / Jan 16, 2009 2:22pm

    wspub

    21 posts

    I’ve tried it inside and outside. Neither work. Outside of the entries tag, I entered in the template:

    {entry_id}

    .

    The correct entry id appeared, leaving to me to believe that it was able to retrieve it inside or out. The problem seems t be in passing it along to the sub-template.

  • #8 / Jan 16, 2009 2:37pm

    Pascal Kriete

    2589 posts

    Let’s try to reduce this a bit.  In a barebone template, with the embed inside the weblog:entries tag, viewing a single entry url.  What do you get if you just output {embed:exclude} in your embed template?

  • #9 / Jan 16, 2009 3:31pm

    wspub

    21 posts

    What do you get if you just output {embed:exclude} in your embed template?

    I get the ID. So that part works. The entries tag in the sub-template breaks as a result. Instead of 5 results, I get 1, and the link shows as {title} instead of the actual entry title.

  • #10 / Jan 16, 2009 3:48pm

    wspub

    21 posts

    I believe I got it working using the query module.

  • #11 / Jan 16, 2009 4:20pm

    Sue Crocker

    26054 posts

    Glad you were able to figure it out. Don’t hesitate to post again if needed.

  • #12 / Jan 16, 2009 4:21pm

    Sue Crocker

    26054 posts

    Now really closing this.

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

ExpressionEngine News!

#eecms, #events, #releases