Forum for discussing general topics related to Couch.
3 posts Page 1 of 1
Hello all,
in the documentation you can read that:
Editable tags cannot be nested within other editable tags.

...what is actualy my issue. Is there any way around?

This is what I would like to do:

There is an ice-cream cafe, which everyday changes its menu. One day there are such tastes of ice-creams avaliable, other day - different. I've created a "menu for today" page, where worker can thick today's menu items from a checkbox:

Code: Select all
<cms:editable
  name="todays_tastes"
  label="Choose menu for today" desc="Which tastes do you serve?"
  opt_values='strawberry | orange | raspberry'
  type='checkbox'
/>


The problem is that he has to choose between choices which has been earlier set (strawberry, oragne, raspberry), even though this ice-cream cafe explores new tastes oftenly.

What I would like to do, is to allow the worker to add new item to the items list, like:
Code: Select all
Taste name: Red dragon
Taste description: Strawberry mixed with banana
Taste image:


...and to make the opt_values value to take "taste name" of an item from the items list, no matter how many of items there are.

Is it possible?


Second issue is:
Later on, on the "menu for today" page, I may want to list all tastes ticked on the checkbox in a special way. How can I make the list appear like:

Code: Select all
<img src:graphic> Orange <br>
<img src:graphic> Strawberry <br>


or:

Code: Select all
<img src:Taste image><br>
<img src:graphic><b>Taste name</b><br>
<description of a taste>


etc.

Thanks in advance.
I think what you are needing to use in this case is the related pages tag - http://docs.couchcms.com/concepts/relationships.html

Your editable region would become:
Code: Select all
<cms:editable
  name="todays_tastes"
  label="Choose menu for today"
  desc="Which tastes do you serve?"
  type='relation'
  masterpage='tastes.php'
/>


You would have to set up a new clonable template called tastes.php

Code: Select all
<cms:template title="Tastes" clonable="1">
    <cms:editable name="taste_description" label="Taste description" type="text" order="1" />
    <cms:editable name="taste_image" label="Taste Image" type="image" order="2" />
</cms:template>


Once this is all set up (and you've added some tastes), you should have checkboxes on the Menu admin page, where you can select multiple tastes for the menu.

To display them on the front end (on the menu page):

Code: Select all
<cms:related_pages 'todays_tastes'>
   <div class="eachtaste">
   <h1><cms:show k_page_title /></h1>
   <p><cms:show taste_description /></p>
   <img src="<cms:show taste_image />" alt="<cms:show k_page_title />">
   </div>
</cms:related_pages>


I hope I've understood you correctly, and that this will help! (Also, I've only recently started using relations, so please forgive any mistakes!)
I'll second @ewanmc's solution. Using relations, as shown by him, would be the correct way of handling this use-case.

Would just like to add that the new template (i.e.tastes.php as termed by @ewanmc) needs to be registered first before adding the type 'relation' cms:editable definition in the existing template (else that definition will throw an error complaining that the related template is not found).
3 posts Page 1 of 1