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

I have created a blog using Couchcms, and in the article template file, I have added this part of code :

Code: Select all
  <cms:editable group='group_main_profile' name="profile_sujet" label="Sujet" opt_values='Attitude | Coaching | Communication non-verbale' type='dropdown'/>


It's appearing in the admin panel, and I am able to make the selected option appear wherever I want.

But that's not what I need. I need to be able to list out all the opt_values from the "profile_sujet" editable dropdown, in another dropdown on the front-end, that appears on every pages of the website.

I just need to clone the data inside that "profile_sujet" dropdown that I can see on the backend, into a specific dropdown on the frontend. And If I ever add a value in "profile_sujet", it will be automatically added on both the backend and that dropdown menu on the front-end.

I tried inserting that part of code into the dropdown element :
<cms:show profile_sujet />

But it's not displaying anything. Again, I don't want it to display the selected value, I need it to display all the options in the "profile_sujet" dropdown.

Thanks!
Hello @pipolamenace,

Dropdown editable in admin panel is needed to select some value from the list of available options. On the front-end you can display this chosen option anywhere with <cms:show />.

It is possible to display all options from this dropdown only inside a form on the front-end as <cms:input /> as part of databound form concept, which enables you to 'link' form on front-end to admin panel editables. http://docs.couchcms.com/concepts/databound-forms.html

If, however, you need only to display some values in the style of dropdown and need no form for that, it is not possible with current setup. You must use some other type of editable regions, like text, repeatable region, or clonable pages. This way you can construct a html <select> and fetch options inside it dynamically from the backend.
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
Hi :)

As @trendoman suggested, one way of doing this could be to use 'repeatable regions' in the admin-panel where each row could represent one option of the dropdown. On the frontened, we can then loop through the repeatable region's rows and create a dropdown.

An easier method, however, could be as follows -
Instead of defining a dropdown in the backend, as you are doing currently, define a 'textarea' instead as follows -
Code: Select all
<cms:editable group='group_main_profile' name="profile_sujet" label="Sujet" desc="Enter values separated by pipe '|' character e.g. 'Attitude | Coaching | Communication non-verbale'" type='textarea' />

Instruct the client to enter within it all the options of the dropdown separated by '|' character. For example
Attitude | Coaching | Communication non-verbale

Now on the frontend, we can output a dropdown using the text entered above as follows -
Code: Select all
<cms:input
    name='my_dropdown'
    type='dropdown'
    opt_values="<cms:show profile_sujet />"
/>

As we are interested in only displaying the dropdown and not in processing the selected option, we can skip the usual <cms:form>..</cms:form> that normally encloses the <cms:input />.

For more on how to create a form (or its inputs) dynamically, please see - viewtopic.php?p=13629#p13629

Hope it helps.
Hi guys,
Thanks for the reply!

The reason I wanted to do it that way is that the options from that dropdown are set in advance.
The client won't have to change them.

I'm building a search form that the user will be able to select the category he wants in a dropdown menu, and other options, then click SEARCH.

I don't want my client to enter each categories manually everytime he creates a blog post. I want him to be able to select it from that dropdown menu in the admin panel...and that these same categories appear in a specific dropdown on the frontend.

Does that make more sense?

How can I make this work? The user cannot enter each categories everytime.

Thanks a lot!
Seems, that it can be achieved by folders (and dynamic folders). In admin client chooses a folder the post goes into. In front-end it's something like
Code: Select all
<select>
   <cms:folders masterpages='news.php' >
      <option value="<cms:show k_folder_name />"><cms:show k_folder_title /></option>
   </cms:folders>
</select>

Or simply
Code: Select all
<cms:dropdownfolders masterpage='news.php' />
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
Thanks.
Sadly it's not working.

I tried

Code: Select all
<select>
   <cms:folders masterpages='article.php' >
      <option value="<cms:show k_folder_name />"><cms:show k_folder_title /></option>
   </cms:folders>
</select>


article.php being the page with folders...and it's displaying an empty dropdown.
I created this little image to show you what I really need.
Image
Do I get it right, that in admin you have let's say 5 cloned pages.
Each cloned page has 1 Sujet, 1 Prix, 1 Prenom, 1 Nom?

If so, then it will be relatively easy.
Post code of your <cms:template> block + code for all front-end dropdowns.

Do you already have code for search? Post it too. Thanks.
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
Hi trendoman
Thanks a lot for replying back.

Each cloned page has 1 unique Prenom and Nom. Yes.
But the "Sujet" and "Prix" are set in advance in a type='dropdown' editable element in the profile.php page.

Here's my code in the profile.php page :

Code: Select all
<cms:template title='Profiles' clonable='1' order="1">
<cms:embed 'fr/category-folders.php'/> <!-- Modal -->

<cms:editable name='group_main_profile' label='Contenu profile' type='group' order='1'>

<cms:editable group='group_main_profile' name='profile_prenom' label="Prénom" type='text' order="1" />
<cms:editable group='group_main_profile' name='profile_nom' label="Nom" type='text' order="1" />


<cms:editable group='group_main_profile' name='profile_content' label="Contenu du profile" type='nicedit' order="3"/>
<cms:editable group='group_main_profile' name='profile_ruban_citation' label="Citation du ruban orange" type='nicedit' order="2"/>
<cms:editable group='group_main_profile' name='profile_ruban_auteur' label="Auteur de la citation du ruban orange" type='nicedit' order="2"/>
  <cms:editable group='group_main_profile' name='profile_soustitre' label="Sous-titre du profile" type='text' order="1" />

   <cms:editable group='group_main_profile' name='profile_image' label="Photo de profile" order="2" type='image'/>

  <cms:editable group='group_main_profile' name="profile_sujet" label="Sujet" opt_values='Attitude | Coaching | Communication non-verbale' type='dropdown'/>
  <cms:editable group='group_main_profile' name="profile_prix" label="Prix" opt_values='0$ - 3500$ | 3500$ et +' type='dropdown'/>

</cms:editable>

<cms:editable name='group_sidebar_profile' label='Barre latéral' type='group' order='2'>
<cms:editable group='group_sidebar_profile' name='profile_sidebar_conferences' label="Titres des conférences possible" type='nicedit' order="1"/>
<cms:editable group='group_sidebar_profile' name="profile_sidebar_video" label="Lien d'intégration du vidéo" desc="Lien Embed" type="text" order="2"/>
<cms:repeatable group='group_sidebar_profile' name='profile_sidebar_livres' label='Livres et DVD' order="3" >
<cms:editable name="img_livres" width="100" label="Image du Livre/DVD" type="image"/>
<cms:editable name='url_livres' label='Lien du Livre/DVD' type='text'/>
</cms:repeatable>

</cms:editable>

</cms:template>


And for the search engine, I haven't coded anything in it yet. I'm not sure how to build it with filters with dropdown like this.
Ok, will take a look! Replied.
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
If anyone interested, this was resolved by creating cms:input type='dropdown' in frontend. Because values were hard-coded in template there was no need to get them dynamically. A copy of opt_values did just fine. So, category and price were covered this way.

Names of people are fetched dynamically for a <select> tag with the use of cms:pages
Two inputs from the frontend (dropdown and text) were replaced by one dropdown Select2 with type suggestions and options feeded by cms:pages. Hidden cms:input with the same name passes selected option value into k_success block of cms:form.

When name is selected, form autosubmits, we set flash variable with set_flash and reload page. cms:pages block gets ID from the get_flash and displays one result.

When any other inputs selected, in k_success a session is created with constructed string, made for custom_field parameter in cms:pages. Page reloads and the same cms:pages shows pages filtered by custom_field, id stays empty.

As a side features, I would point displaying values of inputs from session, so after reload they are not reset; deleting sessions and resetting inputs after name is selected; two paginators on page with position parameter of cms:paginator.
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
10 posts Page 1 of 1