Problems, need help? Have a tip or advice? Post it here.
2 posts Page 1 of 1
Hello,

I have a clonable template page (proposals.php) with a repeatable region that allow me to select some options from a dropdown menu in the first cell, and then to enter some text in a regular input field. Code looks like this:

Code: Select all
<cms:repeatable name='fruit_block' label="Info about your meal">
          <cms:editable name="fruits_options" label="Available fruits" opt_values='fruits-list.html' separator=',' dynamic='opt_values' type='dropdown'/>
          <cms:editable name='fruits_notes' label="Notes" type='text'/>
</cms:repeatable>


Let's say the "fruits-list.html" external opt_values file has the words "Apple, Banana, Orange".

I can fill my "proposal", and once I'm at the repeatable region, I can add the fruits needed, clicking on "Add a row" to add a new fruit to the proposal.

On another page, I am trying to list all proposals matching a fruit name.
Let's call it the fruits.php file.

The "fruits.php" page is also a clonable template page. Each entries are named after the fruits in the "fruits-list.html" file. So for example, my entries could be "Apple", "Banana", and "Orange". 3 entries total.

When I click on the "Apple" page (which is also the title of the page), I want to display all proposals that has "Apple" selected in the previously mentioned repeatable region, so I can so in which proposal I selected an Apple in the options.

But I cannot figure out how to display that information correctly. Here's my code on the "fruits.php" admin page:
(of course, this is wrapped with config_form_view )

Code: Select all
<cms:field 'proposalFruits' label="List of proposals containing this fruit">
<cms:set fruit_title="<cms:show k_page_title/>"/>
<cms:pages masterpage="proposals.php" custom_field="fruits_options=<cms:show k_page_title/>">
Proposals where <cms:show fruit_title/> were used :<br>
<cms:show k_page_title> - Link : <cms:show k_page_link/>
</cms:pages>
</cms:field>


It seems like "custom_field" is not getting that I'm looking for entries with the "fruits_options" region being equal to the current fruit page title, which is, in this example here, "Apple". I thought this would scan each proposals, and show me the ones with "Apple" being selected.

Any idea what I'm doing wrong, and how to fix my issue? Thanks a lot
Found how to do it!
I feel bad for posting topics on stuff that I manage to fix myself, but it's after spending few hours on the issue.
So hopefully, if someone comes across the same kind of issue, this will help.

What I did is this:

First, I have set a new variable, from inside the "masterpage" block, that scans the "fruit_block" repeatable region, and finds the "fruits_options" field from inside that repeatable region. It looks like this:

Code: Select all
<cms:set fruits_list="<cms:get_field 'fruit_block'>
    <cms:show_repeatable k_field_name >
        <cms:show fruits_options/>
    </cms:show_repeatable>
</cms:get_field>"/>


Then, I added a condition inside the masterpage block:
Code: Select all
<cms:if fruits_list=fruit_title>
..
</cms:if>


It checks if the "fruit_options" field from the repeatable region containing the information is equal to the page title of the fruit page you are in, then it will be displayed.

Full code looks something like this:

Code: Select all
<cms:field 'proposalFruits' label="List of proposals containing this fruit">

<cms:set fruit_title="<cms:show k_page_title/>"/>
<cms:pages masterpage="proposals.php">
Proposals where <cms:show fruit_title/> were used :<br>
<cms:if fruits_list=fruit_title>
<cms:show k_page_title/> - Link : <cms:show k_page_link/>
</cms:if>
</cms:pages>

</cms:field>


There's some tweak to do, but I was able to solve my main issue with this solution.
Thank you
2 posts Page 1 of 1