[Fred with pdoResources/getResources] Fred slider used to limit elements and total placeholder

Hi All,

I am trying to integrate Fred for the first time and I am facing some new challenges and the documentation was not clear enough to help me sorting this out.

Note: I am mentioning getResouces / pdoResources on the title as the issue is exactly the same on both elements and hopefully this can help other users seeking for similar issue by landing here.

Here’s the situation:

[Fred]
I have a Fred block that has an OptionSet with a slider that is intended to limit the results shown on the screen.
The idea is to use the same block for a home page where it will list a maximum of X elements defined by the slider, and set a new page that will be intended to list all (by setting slider to 0 using the same block).
here is the option set:

{
  "name": "MaxChildBlocks",
  "label": "Number of elements",
  "type": "slider",
  "min": 0,
  "max": 12,
  "step": 1,
  "value": 6
}

Then on the Fred element itself I am calling a Chunk that also defines extra arguments:

[[$NewsList?
&ParentPageListingID={{ ParentPageListing.id }}
&ParentPageListingURL={{ ParentPageListing.url }}
&MaxChildBlocks={{ MaxChildBlocks }}
&ChildBlocksType={{ ChildBlocksType }}
&ShowMainTitle={% if ShowMainTitle %}{% else %} d-none{% endif %}
&ShowSummary={% if ShowSummaryLevel1 %}{% else %} d-none{% endif %}
]]

[getResources / pdoResources]
Now on the chunk side I have this pdoTools markup:

[[pdoResources?
&parents=[[+ParentPageListingID]]
&depth=[[+ChildBlocksType]]
&limit=[[+MaxChildBlocks]]
&sortby={"parent":"ASC","menuindex":"ASC"}
&setTotal=1
&tpl=NewsList-OneLevel
&tplWrapper=NewsList-OneLevelWrapper
&showLog=0
]]

As you can see I am limiting the number of elements on the screen using the fred slider.
On the wrapper template I will need to add a link that will list all the elements:

<a class="d-table px-3 py-2 my-3 text-center generic-button blue-on-white mx-auto mx-md-0" href="[[~[[+id]]]]">List All</a>

[The Problem]

I am trying to find a way to create a condition that has the following conditions:

  • Evaluate the number of limited items by Fred;
  • Compare with the total number of elements existing in the Database coming on the [[+total]] placeholder;
  • The objective is to show the button only if the number of total elements ([[+total]]) is less or equal than the Fred limiter number;

I tried this that seems to work:

[[+total2:gt=[[+MaxChildBlocks]]:then=Show the button]]

But how can I state that the button should not be visible also when [[+MaxChildBlocks]] is 0 (so Fred can list all elements without limits)?

Many thanks in advance.
NOTE: the forward quote delimiters are not visible because the forum parses them as code block, sorry

Hi All,

Problem solved:

    [[+MaxChildBlocks:lt=`[[+total2]]`:and:isnot=`0`:then=`
        <a class="d-table px-3 py-2 my-3 text-center generic-button blue-on-white mx-auto mx-md-0" href="[[~[[+id]]]]">List All</a>
    `]]

Now the button appears when slider is set to 0.
Hope this helps the community.

Cheers all,
J. Nogueira

This topic was automatically closed 2 days after discussion ended and a solution was marked. New replies are no longer allowed. You can open a new topic by clicking the link icon below the original post or solution and selecting “+ New Topic”.