Articles Anywhere

Second random article on same page

4 months 5 hours ago #89718

Seppi's Avatar Seppi

Hi there

We need to display multiple random articles on the same page. They are all in the same category, but they should never show twice.

So at position a we have this:
{articles category="17" ordering="random" limit="1"}
[title]
[text]
{/articles}

And at position B (on the same page) we have exactly the same thing:
{articles category="17" ordering="random" limit="1"}
[title]
[text]
{/articles}

How can we achieve that that never the same article shows on position a AND b? Is this possible?

Many thanks in advance.
Best regards

4 months 2 hours ago #89719

Peter van Westen's Avatar Peter van Westen Admin

The separate articles blocks are not connected. So there is no way to do this via the filters.
Are these blocks in different modules? Or in the same content area?

3 months 4 weeks ago #89731

Seppi's Avatar Seppi

Thanks for the fast reply! OK, that's what I feared. Unfortunately yes, they are in different content areas (page builder elements).

So there is no way to do this via the filters - is there no way to do this at all?

Confidential information:
(hidden)

3 months 4 weeks ago #89732

Peter van Westen's Avatar Peter van Westen Admin

No, I don't see a way you could do this with Articles Anywhere. You would have to do this via php in some way.

3 months 4 weeks ago #89733

Peter van Westen's Avatar Peter van Westen Admin

Or maybe have Articles Anywhere output 2 random articles in position A.
Then use ReReplacer to move the second one to position B with some fancy Regular Expression magic.

3 months 4 weeks ago #89734

Seppi's Avatar Seppi

Okay, that's a good idea. We'll see if my skills suffice (had a window seat in RegEx class at Hogwarts 😉 ).

Awesome and fast support, as always - thanks!

3 months 4 weeks ago #89737

Peter van Westen's Avatar Peter van Westen Admin

To help with locating the block of content you want to find and move, you cold do something like:

<p>{articles category="17" ordering="random" limit="2"}</p>
<!-- START -->
<div class="random-article-[count]">
<h3>[title]</h3>
<p>[text]</p>
</div>
<!-- END -->
<p>{/articles}</p>