Search
Other Articles Anywhere questions
Forum

Struggle with if-selse Syntax

Thomas Venugopal's Avatar Thomas Venugopal
Hello,

I have a button like this:
<a href="{articles}{if id = this:id}[sefurl]/order{/if}{/articles}">{articles id="input:btn"}[text]{/articles}</a>

I can display the button on my page with an URL parameter like this ?btn=1. As you can see there is a dynamic button text. That button text gets only displayed when a parameter is provided.

Question: How do I define a fallback text for the button, if no parameter is provided?

I tried it with the if/else syntax but I'm struggling. This and many other variations didn't work:
{articles id="input:btn" ignore-state="true"}
            {if input:btn="input:btn"}
               {articles id="input:btn"}[text]{/articles}
            {else}
               Fallback-Text
            {/if}
          {/articles}

Thanks in advance for any hint!

Greets
Thomas
Peter van Westen's Avatar Peter van Westen ADMIN
Try:
{if input:btn}
   {article id="input:btn"}[text]{/article}
{else}
   Fallback-Text
{/if}
Or:
{article id="input:btn" empty="Fallback-Text"}[text]{/article}
Or:
{article id="input:btn" empty="Fallback-Text"}
   [text]
{article-else}
   Fallback-Text
{/article}

Also, instead of
{articles}{if id = this:id}[sefurl]/order{/if}{/articles}
Just do:
{article}[sefurl]/order{/article}
Please post a rating at the Joomla! Extensions Directory
Thomas Venugopal's Avatar Thomas Venugopal
Thank you very much, will try it.
Thomas Venugopal's Avatar Thomas Venugopal
Worked great, thanks again. But I stumpled into another problem.

I write this:
{article category="266" id="input:hl" empty="Fallback"}[text]{/article}

I would expect that if I provide an article-ID for the hl parameter which is not within the category 266 that the fallback gets shown. But I'm still able to manipulate URL to show article data from articles of categories other than id 266. In this case I'm able to show a headline in a button but I want to prevent this.
Peter van Westen's Avatar Peter van Westen ADMIN
Try using the multiple {articles} tag instead.
Please post a rating at the Joomla! Extensions Directory
Thomas Venugopal's Avatar Thomas Venugopal
Thank you, works!
Thomas Venugopal's Avatar Thomas Venugopal
Sorry, me again.

I have this:
{articles category="265" ordering="id"}<span style="background:{articles category="265" id="input:hl" empty="#a5a5a5"}#3dc372{/articles};">[id]</span>&nbsp;&nbsp;[text]<br>{/articles}

If the URL has the parameter hl with a value the background color of the corresponding id should be highlighted. My code highlights everything, which is not what I want. I tried a lot but didn't make it work. Is it possible at all? For example: I do this ?hl=123 the element with the article-ID 123 should have another background.

Confidential information:
(hidden)
You can only post on the extension support forum if you have an active subscription and you log in

Buy a Pro subscription