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

I want to use this technique : viewtopic.php?f=8&t=7097
but with Folders instead. While I can easily load the url, title name etc I wanted a little more control over the <option> list so I could output in the CMS:

Template editable:
Code: Select all
<cms:editable
      name="case_study_study_work"
      label="Related Work Link"
      desc="Select the work to link to"
      opt_values='work_list.txt'
      dynamic='opt_values'
      type='dropdown'
      order='25'
   />



Work List Folder file:
Code: Select all
<cms:folders masterpage='our-work.php' hierarchical='1' depth='2'>
<cms:if k_level='1'>
<cms:show k_folder_title />|
</cms:if>
</cms:folders>


the desire format then for the admin panel dropdown would output:

Code: Select all
<option value="<cms:show k_folder_link />"><cms:show k_folder_name" /></option>


rather than using the pipe| method.

Basically this will allow the cleint to select a work item to link to rather than using relationships which I cant see how to use with Folders? It seems to list images etc and a bit messy.

Furthermore - is it possible with a PHP SQL query to get a list of every page and clonable in the site to create a typeahead field in the CMS for the user to link to a page without having to type the whole URL / copy it from the front end? A bit like you have with Expression Engine in a Module for Structure called Structure Pages.
Hi,

The syntax for option values (as explained in the docs) is
Code: Select all
opt_values='Residential=0 | Commercial=1 | Rental=2'

which will translate to
Code: Select all
<option value="0">Residential</option>
<option value="1">Commercial</option>
<option value="2">Rental</option>

So, we can use this syntax in your 'work_list.txt' file to generate folder names with their links as values.

However, instead of the hard-coded links as values, I suggest you use 'folder names' instead.
We can always generate the link on front-end given a folder-name.
This will be more future-proof in the sense that if a link changes, it won't affect saved pages.

This is what we can place in the 'work_list.txt' file -
Code: Select all
<cms:folders masterpage='our-work.php' hierarchical='1' depth='2'>
    <cms:if k_level='1'>
        <cms:show k_folder_title />=<cms:show k_folder_name />|
    </cms:if>
</cms:folders>

Now whatever value is saved in the editable region will, of course, be available to us as
Code: Select all
<cms:show case_study_study_work />

We can use that in the template to generate the link as follows -
Code: Select all
<cms:link masterpage='our-work.php' folder="<cms:show case_study_study_work />" />

Hope this helps.

Regarding your other question about the 'typeahead', Couch natively, I am afraid, has nothing currently to this effect.
Thanks KK, works a treat! Sorry i missed that in the docs, very very handy feature indeed (opt values).
Glad it helped :)
4 posts Page 1 of 1
cron