Problems, need help? Have a tip or advice? Post it here.
10 posts Page 1 of 1
Hi,
I'm wondering if it's possible to catch some variables from one template and use them in anothers dropdown region. I guess this must be possible, but my code just won't bring his A-game :)
Code: Select all
<cms:template title='Events' executable='0' clonable='1'>
  <cms:pages masterpage='_php/cms_senseiDB.php'>
     <cms:set get_sensei="| <cms:show k_page_name  />" />
     <cms:add all_sensei get_sensei 'global' />
  </cms:pages>
<cms:editable name="event_sensei_1"
  label="First sensei"
  opt_values="Please Select=- <cms:show all_sensei />"
  type='dropdown'
  group='event_sensei'
/>
</cms:template>
<?php
COUCH::invoke();
?>


Of course I would have to reload the template every time I add a page in cms_senseiDB.php
Hi,

Instead of using cms:add try cms:concat.
http://www.couchcms.com/docs/tags-reference/concat.html
concat didn't work, but this did the trick:
Code: Select all
<cms:set all_sensei=""/>
<cms:pages masterpage='_php/cms_senseiDB.php'>
<cms:set get_sensei="| <cms:show k_page_name  />" />
<cms:set all_sensei="<cms:show all_sensei/> <cms:show get_sensei />" 'global'/>
</cms:pages>

Guess concat shall be the short version of this? Anyway, thank you very much for your help, again! :)
Glad it worked.
Concat should work too if used like this
Code: Select all
   <cms:pages masterpage='_php/cms_senseiDB.php'>
      <cms:set get_sensei="| <cms:show k_page_name  />" />
      <cms:concat all_sensei get_sensei 'global' />
   </cms:pages>
Perhaps you'd like to check out this undocumented feature of Couch -

Create a snippet and, say, name it 'my_dynamic_params.htm' (IMP: make sure to place it only within 'couch/snippets' folder).
Place the following code in the snippet -
Code: Select all
Please Select=-
<cms:pages masterpage='_php/cms_senseiDB.php'>
   | <cms:show k_page_name  />
</cms:pages>

Now make the following changes to your original definition of the dropdown editable region -
Code: Select all
<cms:editable name="event_sensei_1"
   label="First sensei"
   opt_values='my_dynamic_params.htm'
   dynamic='opt_values'
   type='dropdown'
   group='event_sensei'
/>

Refresh your template for the changes to take effect.
Now when you edit the page in the admin panel, the dropdown should dynamically fetch in the pages of the other template. Any changes done to '_php/cms_senseiDB.php' will automatically be reflected here.

To explain the code - we are using a (undocumented) parameter 'dynamic' and telling it that 'opt_values' is the field that instead of containing the usual static value, actually needs to be filled dynamically by using the snippet that is its value.
The value in 'opt_values' ('my_dynamic_params.htm') is executed by Couch and the result is placed as the computed value of 'opt_values'.

'my_dynamic_params.htm' simply outputs the concatenated values required by the dropdown, using the 'pages' tag.

This feature was considered to be a littles advanced for now so we did not document it. But it seems you are trying to do exactly what this feature was built to do so perhaps it'll be useful to you.
Please try it out and let me know.

Thanks.
Works like a charm! Thanks!!!!
Hi everybody,

I would like to know if there is a way to catch more variables than the page_name from a clone-able page, but show only the page-name in the drop down menu?

For example:
I have a clone-able page were all contact infos from several members are stored. From this page I would like to get the data and show them in specific pages at the sidebar.
For example there is an article which belongs to two of the members. Then I would like to show their contact infos in the sidebar and it would be very nice if I had just a drop down menu in the back-end to choose from than typing in all contact infos again and again.

My idea was to put the code above into a repeatable region which contains only a drop-down menu with the member names.

Is that possible?
Hi cl,

This seems like the perfect job for 'relationships' (http://www.couchcms.com/docs/concepts/r ... ships.html).

Create an editable region of type 'relation' in the 'articles' template linking it to the 'members' template. Now whenever an article is edited, you'll get a dropdown showing all the members where you can choose the members associated with the article.

On the frontend, you can easily list these members and fetch all the info associated with them (i.e. values from all the editable regions defined in members template).

Does this help? Please let me know.
Thanks.
Thank you, works perfect!!! :D
Can you show me the file _php/cms_senseiDB.php, would like to know whats inside. is _php choosen to hide it from guessing the folder name?
* * * * * * I LOVE COUCH CMS - flexible and straight forward * * * * * *
10 posts Page 1 of 1