Articles Anywhere

The linked article is not there and then???

1 month 3 weeks ago #89921

Anita Kooistra's Avatar Anita Kooistra

Hello,

We have linked articles with the alternative "Articles - Linked” field type and thanks to Articles Anywhere
we would like to have in the output that when there is no article linked to the current article, it
should state the default article. In our case that is the article 'Review vragen'.
How do you advise to do that? 🤔
We have following, but it does not work
Best regards, Anita

<p>{if articles category="Reviews" review-of-event="this:id"} [link][title][/link]<br /> {if image-intro} <img src="[image_intro]" alt="logo [title]" />{else}
 <img src="images/referenties/default-profiel.jpg" alt="default profilepicture" width="100" height="100" />{/if} 
 {else} {article Review vragen}[introtext]{/article}<br /> [introtext]<br /> {/articles}{/if}</p>

1 month 3 weeks ago #89928

Peter van Westen's Avatar Peter van Westen Admin

That is not the correct syntax. Please read the documentation and watch the tutorial videos on how Articles Anywhere works and what the syntax is:
www.regularlabs.com/extensions/articlesanywhere/tutorial
www.regularlabs.com/extensions/articlesanywhere/videos

The {if} tags should be between the outer {articles} tags.

2 weeks 22 hours ago #90604

Anita Kooistra's Avatar Anita Kooistra

Peter van Westen wrote:

That is not the correct syntax. Please read the documentation and watch the tutorial videos on how Articles Anywhere works and what the syntax is:
www.regularlabs.com/extensions/articlesanywhere/tutorial
www.regularlabs.com/extensions/articlesanywhere/videos

The {if} tags should be between the outer {articles} tags.

The if-statement for the intro image works very well, so we did understand that part, but somehow we cannot get it to work with the content of the articles 🤔 . The intention of this code is that the review of a particular event will be given here, but when there is no review, it must state the default article 'Review vragen'. We get it to do the first part, it will give the correct review of that particular event, but the second part won't work 🙁 .

We have looked through RL's tutorial and videos, searched on the web, tried and searched again, but it will not do what we need it to do. We don't know where to put the {if} {/if} and {else} {/else} anymore 😲 .
The code has slightly changed, so here it is what we have now:
<p>{articles category="Referenties" referentie-van-uitje="this:id"}
	[link][title][/link]
</p>
<p>
	{if image-intro} 
<img class="img-overzicht-ref-ak" src="[image-intro-url]" alt="logo [title]" /> 
{else} 
<img class="img-overz-refprofiel-ak" src="images/referenties/default-profiel.jpg" alt="default profile picture" width="100" height="100" /> 
{/if}
<br />	[volledig-artikel]<br />
	{else} {article Review vragen} [introtext] {/article} {/else}
{/articles}
</p>

Will Conditional Content help us with this problem?
Hope anyone can help us, so we can get on with this site 🙂 .
Thanks in advance 😉 .

2 weeks 21 hours ago #90606

Peter van Westen's Avatar Peter van Westen Admin

To dumb the code down, you currently have:

{articles ...}
   {if image-intro} 
      ...
   {else} 
      ...
   {/if}

   {else} 
      {article Review vragen} [introtext] {/article}
   {/else}
{/articles}

There is no such thing as a closing {/else} statement.
The {else} is part of an {if ...} ... {/if} block.

So if you want a second conditional thing, create a second if/else block.

However, I think all you want is to show something else if the main {articles} tag returns nothing.
That is where the empty="" attribute is for.
{articles ... empty="Nothing found!"}
{/articles}
See: www.regularlabs.com/extensions/articlesa...ut-output-when-empty

However, it is currently not possible to place nested {article} tags inside the empty="..." attribute.

2 weeks 20 hours ago #90608

Peter van Westen's Avatar Peter van Westen Admin

What you could do is use ReReplacer to deal with the showing of that "Review vragen" article.
Your articles tag could be:

{articles category="Referenties" referentie-van-uitje="this:id" empty="[oeps-geen-referenties]"}

Then with ReReplacer you can replace:
[oeps-geen-referenties]
With:
{article Review vragen}[introtext]{/article}

You will have to play around with the system plugin ordering and the ReReplacer Search Area setting to get this to play nice.

2 weeks 18 hours ago #90611

Anita Kooistra's Avatar Anita Kooistra

Peter van Westen wrote:


However, I think all you want is to show something else if the main {articles} tag returns nothing.
That is where the empty="" attribute is for.
{articles ... empty="Nothing found!"}
{/articles}
See: www.regularlabs.com/extensions/articlesa...ut-output-when-empty

However, it is currently not possible to place nested {article} tags inside the empty="..." attribute.

Thank you for your help with this problem, it is solved 😁 😁 😉 👍
Because you informed me that it not possible is to place nested {article} tags, I just wrote the sentence including the link (as html) to the contactform between the "...". And it works great!!

Again thank you for explaining yet another possibility how to use this great extension 😉

greetings, Anita