Search
Other Articles Anywhere questions
Forum

Using if nested

Luis's Avatar Luis
Hi, I'm struggling with using two conditions that cannot be together.

The idea is ti just show the content if its published, but that content may or may not have a coundown, pending on a custom field value. I've tried the nested structure but without success, could you help?

Here the code:

{article Barra de Topo - Dreambooks1}
{if is-published}
<div id="interacao" class="custom uk-grid-small" uk-grid>
{if field:350 == 'true'}
<div uk-countdown="date: [publish-down format='c']">
Sets up a countdown
</div>
{/if}
<div>
[text]
</div>
</div>
{/if}
{/article}
Peter van Westen's Avatar Peter van Westen ADMIN
You cannot nest ifs. But why not use the is-published check in the filters?
{article title="..." is-published="true"}
...
{if field:350}
...
{/if}
...
{/article}
Please post a rating at the Joomla! Extensions Directory
Luis's Avatar Luis
It return:

Unknown column 'article.is_published' in 'where clause'
Peter van Westen's Avatar Peter van Westen ADMIN
Please try the latest development version from:
regularlabs.com/development-releases

Alternatively you can do:
{article title="..." state="1"}
...
{if field:350}
...
{/if}
...
{/article}
Please post a rating at the Joomla! Extensions Directory
Luis's Avatar Luis
Worked with 13.0.2
Peter van Westen's Avatar Peter van Westen ADMIN
Ok, great 🙂
The fix will be included in the next release.
Please post a rating at the Joomla! Extensions Directory
Vinny Hebert's Avatar Vinny Hebert
I know you said you can't use nested if structure, but did read about Nested Articles Tag.
<ul class="uk-slider-items uk-child-width-1-1 uk-child-width-1-3@s uk-grid">
                {articles category="Events" tags="DJing" ordering="event-date ASC"}
				{if count = 0}
				<li>
					<h3>No Public Events</h3>
				</li>
				{else}
				<li>
					<div class="uk-inline-clip uk-transition-toggle" tabindex="0">
						[link][event-image class="uk-border-rounded"][/link]
						<div class="uk-transition-fade uk-position-cover uk-overlay uk-overlay-default uk-flex uk-flex-center uk-flex-middle" >
							<div class="uk-overlay uk-dark uk-position-center uk-text-center">
								<<p class="uk-margin-remove">[event-date]{article-nested id="[id]"}{if end-time} -[end-time]{/if}{/article-nested}</p>
						<p>[venue-name]</p>
						[readmore text="More Info" class="button button-bevel"]
							</div>
						</div>
					</div>										
				</li>
				{/if}
			{/articles}
                
            </ul>


If there is no articles It's suppose to print the text. It is blank. Everything in the {else} tag works.
Peter van Westen's Avatar Peter van Westen ADMIN
The count can never be 0.
The {articles} tag returns a collection of articles.
Then whatever you place between the tags is repeated for every article in that collection.
If the collection is empty, then there is nothing to repeat. So it will never get to that {if} tag.

You can use the empty="..." attribute to output something when there are no results.

See: docs4.regularlabs.com/articlesanywhere/p...gs#output-when-empty
Please post a rating at the Joomla! Extensions Directory
Vinny Hebert's Avatar Vinny Hebert
That makes sense. I am aware of the empty attribute but I wanted to put more than just text there like a link and some styling. That's why I was hoping to this approach.
Peter van Westen's Avatar Peter van Westen ADMIN
You can put (basic) styling and links in there.

Or you could output a {snippet} tag and let Snippets replace it with whatever you want.
Make sure the Snippets system plugin is ordered after Articles Anywhere in that case.

Or output some other placeholder and let ReReplacer deal with it.
Please post a rating at the Joomla! Extensions Directory
Vinny Hebert's Avatar Vinny Hebert
You are amazing! Is there anything you haven't thought through?
Peter van Westen's Avatar Peter van Westen ADMIN
😉
Please post a rating at the Joomla! Extensions Directory
Peter van Westen's Avatar Peter van Westen ADMIN
PS: These all work in my tests (Joomla 4):
Please post a rating at the Joomla! Extensions Directory
Peter van Westen's Avatar Peter van Westen ADMIN
Would it be helpful if this was possible?
{articles category="Events" ...}
   <li>...</li>
{articles-else}
   <h3>No Public Events</h3>
{/articles}
Please post a rating at the Joomla! Extensions Directory
Vinny Hebert's Avatar Vinny Hebert
That would be amazing! I'm currently using the Snippets suggestion as it is cleaner looking.
Peter van Westen's Avatar Peter van Westen ADMIN
Please try the latest development version from:
regularlabs.com/development-releases

(Joomla 4 only)
Please post a rating at the Joomla! Extensions Directory
Vinny Hebert's Avatar Vinny Hebert
Installed and tested and it works as desired
Peter van Westen's Avatar Peter van Westen ADMIN
Ok, great 🙂
The new feature will be included in the next release.
Please post a rating at the Joomla! Extensions Directory
Vinny Hebert's Avatar Vinny Hebert
It may seem like a small thing but its huge.
You can only post on the extension support forum if you have an active subscription and you log in

Buy a Pro subscription