Problems, need help? Have a tip or advice? Post it here.
4 posts Page 1 of 1
This is kind of a complex question.

Let's say I have a workers.php page that contains a lot of worker user profiles.

Let's also consider I would have a proposals.php page. That would be used to create proposals for clients.

In each proposals, the user would have to select which workers would fit the job best.
So when filling a proposal in the admin panel, the user would see a list of all the workers, being able to check which one he would like to add, since he must be able to add multiple workers on the same proposal.

When a worker is added, a little "card" is added on the proposal, containing the photo, bio, and portfolio of the worker.
That card would also contain a "rate/price" section that would also be populated based on the worker profile.

What I need to be able to do, is if for some reasons, the user fills a proposal, and that he must lower the price for a specific worker, or for all of them, for THAT specific proposal (not alter the default value from the workers profile), the user would need some sort of a text field attached to each workers in the proposal page that would let him enter a "edited" price for the job.

The way I thought of doing it would be by using repeatable regions. But I don't know how to make a link between the checked name (worker) and the edited price tag, so that Couch understands that if "John Doe" is selected in row #1 of the repeatable region, it should display his "info card" on the proposal (I'm ok with that part), and that if something is entered for the edited price in the 2nd column of that same John Doe repeatable region row, then it should display whatever is inside that field instead of the "price" field in the Worker profile page.

I thought of doing it that way (in my project it was working better by using an external file for the values. And anyways, I cannot use relation dropdown menus inside of a repeatable region if I remember correctly. So that works for me):

Code: Select all
<cms:repeatable name='workers_options' label="Select your workers">
     <cms:editable name="workers_list" label="Workers" opt_values='workers-list-file.html' separator=',' dynamic='opt_values' type='radio' />
      <cms:editable name='worker_edit_price' label="Edit default price value?" type='text' />
</cms:repeatable>


And then, on the proposal frontend :

Code: Select all
     <cms:set workers="<cms:show_repeatable 'workers_options'><cms:show workers_list />,</cms:show_repeatable>"/>
     <cms:pages masterpage="workers.php" page_title="<cms:show workers />">
          <div class="worker-photo" style="background-image:url('<cms:show profile_photo/>')"></div>
          <h4><cms:show k_page_title /></h4>
          <p><cms:show worker_bio /></p>
          <div>Pricing : <cms:show default_pricing/>$</div>
       </cms:pages>


I tried using "if" conditions, but I cannot find a way to check that the pricing entered in that edit price should match the name of the worker, and be placed instead of the "default_pricing" region if it is filled. But only for that worker.

It is very complex for me to explain this issue since I am not a native english speaker. I hope you will understand.
Thanks a lot!
Hi Marc,

Since you posted this in "Bug Reporting and Troubleshooting" subforum, could you point out to the bug or an isolated non-working code piece, please? It's hard to understand what exactly is not working for you..
Hi,

I have made an image of what needs to work.
Image

So basically, right now, I am able to display the workers with the repeatable region, adding rows and selecting the worker for each rows. One row = 1 worker added to the proposal.

If "John Doe" is selected, it will go find his bio, photo, and more, from his profile in the "workers.php" page.
In that Workers page, there is a Pricing field, which is the default price value for each workers.
I need to be able to tell Couch :

"If I select John Doe, show his info card with the information from the "workers.php" file. If there is something entered in the "Change default price?" field of the row John Doe is selected, override the "Pricing" field content from the "workers.php" page matching John Doe, with what has been entered here.

So I thought of :

Code: Select all
 <cms:set workers="<cms:show_repeatable 'workers_options'><cms:show workers_list />,</cms:show_repeatable>"/>
     <cms:pages masterpage="workers.php" page_title="<cms:show workers />">
          <div class="worker-photo" style="background-image:url('<cms:show profile_photo/>')"></div>
          <h4><cms:show k_page_title /></h4>
          <p><cms:show worker_bio /></p>
          <div>Pricing : <cms:if worker_edit_price><cms:show worker_edit_price/><cms:else /><cms:show default_pricing/></cms:if>$</div>
       </cms:pages>


But it's not working.
I tried with
Code: Select all
Pricing : <cms:show_repeatable 'workers_options'><cms:if worker_edit_price><cms:show worker_edit_price/></cms:if></cms:show_repeatable>


But it's repeating the worker card for the amount of rows there is in the repeatable region. Which creates duplicates.

Hopefully this will help you understand the situation a bit more.
Thanks a lot!
I managed to find how to do it!

Here's how :

Code: Select all
<cms:set workers="<cms:show_repeatable 'workers_options'><cms:show workers_list />,</cms:show_repeatable>"/>
     <cms:pages masterpage="workers.php" page_title="<cms:show workers />">
          <div class="worker-photo" style="background-image:url('<cms:show profile_photo/>')"></div>
          <h4><cms:show k_page_title /></h4>
          <p><cms:show worker_bio /></p>
          <div>Pricing : <cms:show_repeatable 'workers_options' ><cms:if k_page_title== workers_list ><cms:show worker_edit_price/></cms:if></cms:show_repeatable>$</div>
       </cms:pages>


What I have changed is the "Pricing" line.
What it does is that it checks if the Worker's name (page title) is equal to the selection made in the repeatable region radio buttons region (workers_list), it displays the price of that row.

Works perfectly. I'm really happy to have found a solution to this issue :)
Hopefully this will help other people
4 posts Page 1 of 1