Question

I try to hide the getPage [[+pageNav]] Placeholder if there is no pagination. But I can't do the following.

[[!+pageNav:notempty=`<ul class="overview__pagination">[[!+pageNav]]</ul>`]]

Does someone know how I can hide the element with an apropriate output filter? (without own extra snippet). I also tried the following and some other (not likely to work variations).

[[!+pageNav:isnot=``:then=`<ul class="overview__pagination">[[!+pageNav]]</ul>`]]`
Was it helpful?

Solution

Are you calling that code in a chunk that is cached?

Otherwise i've experienced this aswell and it seems custom placeholders sometimes behave that way, it's probably due to the fact that they actually have some unprocessed value during the IF computation but when it's actually output you see nothing. Or that the value is somehow "null" instead of "" while modx output filter might do a strict comparison.

If you're not calling it in a cached chunk or part of code, i suggest first trying with another getPage placeholder such as pageCount or total. Like:

[[!+pageCount:gt=`1`:then=`<ul class="overview__pagination">[[!+page.nav]]</ul>`]]

If that still doesn't work, a last resort in the form of a simple snippet will always solve it, like:

[[!outputPagination? &total=`[[+total]]` &limit=`XX` &output=`<ul class="overview__pagination">[[!+page.nav]]</ul>`]]

In snippet:

if ($total > $limit) {
    return $output;
}

OTHER TIPS

Shouldn't it be...

[[!+page.nav:notempty=`<ul class="overview__pagination">[[!+page.nav]]</ul>`]]

Well, there is a much more easier way to do it than in the first answer. It's like TheMistaC says, even if my answer is a lot easier:

[[!+page.nav:notempty=`
[[!+page.nav]]
`]]

I use it to display a list of articles with getResources, so I know this works fine.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top