R
R
RushV2022-01-09 15:02:59
MODX
RushV, 2022-01-09 15:02:59

How to write a condition for editing a ModX slider?

Hello!
There is a slider output, is it possible to write a condition if there is a slide, then show it, and if not, then hide it?
Like this.


Thank you in advance!

Answer the question

In order to leave comments, you need to log in

[[+comments_count]] answer(s)
A
Alexey Golyagin, 2022-01-11
@RushV

1. To display products, you need to abandon pdoPage and use either PdoResorses or msProducts (rather it).
2. Both PdoResorses and msProducts have a tplWrapper parameter - a wrapper chunk (let it be a similarAds chunk ) where you want to put your output (I optimized your code a bit):

<h3 class="text-uppercase text-dark py-4">Похожие объявления</h3>
<div class="slider">
  	<div class="owl-carousel similar-product mb-4 px-3">[[+output]]</div>
</div>

Further, call with the wrapIfEmpty parameter equal to 0:
[[!msProducts? 
    &parents=`0`
    &resources=`-2`
    &includeContent=`1`
    &tpl=`tpl.Item`
    &tplWrapper=`similarAds` 
    &wrapIfEmpty=`0`
]]

D
Dmitry, 2022-01-09
@i__dmitry

And what's the problem if your "Like this" solves the problem?
And even more beautiful on Fenom:

{if $slider}
...
{else}
...
{/if}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question