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.

Embed & Conditionals

June 26, 2007 9:08am

Subscribe [2]
  • #1 / Jun 26, 2007 9:08am

    Mikee Bee

    179 posts

    Right, I’m losin’ me marbles..

    I want it so that if the backlink part in the embed tag is populated a link appears on the page

    Template group news/diary-dates

    {embed="includes/nav-col" backlink="{homepage}/news/news-listing"}

    Template group includes/nav-col

    {if "{embed:backlink}"}
    
    <a href="http://{embed:backlink}">back</a>
    
    {/if}

     

    But nothing is appearing. If I put {embed:backlink} in the nav-col template it appears its just the conditionals that are playing up.

    ???

  • #2 / Jun 26, 2007 10:51am

    silenz

    1651 posts

    I think I’m not sure what you are trying to do in the first place.

    I want it so that if the backlink part in the embed tag is populated a link appears on the page

    {embed="includes/nav-col" backlink="{homepage}/news/news-listing"}

    {homepage} is a global variable that contains the link to the homepage. Even if this worked they way you try, the backlink part in the embed tag would always be populated. At least with “/news/news-listing”.
    So there is no condition here. Which means

    {if "{embed:backlink}"}
    <a href="http://{embed:backlink}">back</a>
    {/if}

    will always be true.

    You could as well do

    <a href="http://{homepage}/news/news-listing">back</a>

    in the nav-col template. Nothing gained, nothing lost.

    I can’t follow what the conditional part is supposed to achieve anyway.
    Do you want a backlink to appear if the current page is not the homepage? I don’t think so because if you are in news/diary-dates, it’s clear you are not on the homepage ...
    Care to elaborate in words what you are trying to do?

  • #3 / Jun 26, 2007 11:01am

    Mikee Bee

    179 posts

    The backlink changes depending on the template but there are occasions where I don’t want the backlink to appear at all hence the {if}.

    Depending on the template sometimes my embed will just be…

    {embed="includes/nav-col"}

    i.e. no backlink

    Does that make it any clearer?

  • #4 / Jun 26, 2007 11:41am

    silenz

    1651 posts

    Well the example in the first post does work in principle if you make sure that backlink is either filled with a a value or completely empty.
    I can’t tell the conditions on which what would go in there without the context.

    Also global variables like {homepage} cannot be used inside the {embed} because they are obviously parsed after it.

  • #5 / Jun 26, 2007 11:49am

    Mikee Bee

    179 posts

    Hmm ok thanks, I really can’t see what the problem is! Grrr… anyway.

    The {homepage} inside the {embed} seems to work fine by the way.

    Thanks so far

  • #6 / Jun 26, 2007 12:04pm

    silenz

    1651 posts

    The {homepage} inside the {embed} seems to work fine by the way.

    You’re right. Only shows up strange in template debugging.

    So what condition determines whether a backlink is to be shown or not?

  • #7 / Jun 26, 2007 12:21pm

    Mikee Bee

    179 posts

    I’m just populating the contents of the backlink in each template so in news/news-listing/detail there will be

    {embed="includes/nav-col" backlink="{homepage}/news/news-listing"}

    in the template

    and in products/detail there will be

    {embed="includes/nav-col" backlink="{homepage}/products"}

    Just to get to the previous page but there are some cases like on products where there is nowhere to go “back” to so I don’t want the backlink to appear so I would have…

    {embed="includes/nav-col" backlink=""}

    or

    {embed="includes/nav-col"}

    Which are both the same aren’t they? I’ve tried both anyway

  • #8 / Jun 26, 2007 12:48pm

    silenz

    1651 posts

    Sorry, it took me so long but now I understand your problem.
    I think the problem with the conditional is related to the fact that indeed the variable {homepage} is passed in the backlink-parameter and not its value.

    So {embed:backlink} really contains “{homepage}/news/news-listing”. Which prints fine but isn’t evaluated correctly in the contidional.

    In case all your backlinks contain {homepage}, you could just leave it out of the first template and put it into the embedded one, since you don’t need to pass it anyway.

    Template group news/diary-dates

    {embed="includes/nav-col" backlink="/news/news-listing"}

    Template group includes/nav-col

    {if "{embed:backlink}"}
    <a href="http://{homepage}{embed:backlink}">back</a>
    {/if}

    That is gonna work.

  • #9 / Jun 26, 2007 12:55pm

    Mikee Bee

    179 posts

    Pardon my francais but ahem… “You f*cking beauty”. I really did think I was going crackers!

    Thanks so much

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

ExpressionEngine News!

#eecms, #events, #releases