Forum for discussing general topics related to Couch.
4 posts Page 1 of 1
Hi,

I'm using extended folders as product categories, I was wondering if it is possible to find a folder based on a custom_field value. If it was a page I would use:

Code: Select all
<cms:pages masterpage="s/index.php" custom_field="external_id_number">
  <cms:show k_page_id/>
</cms:pages>
Hi,

Depending on exactly what info you wish to extract from the folder you are trying to find, there can be a couple of solutions.

Assuming the template is named 'service.php' while the extended-folder template is named 'service_folders.php' -
1. If the info is actually stored in editable-regions defined in the extended-folder template, it would be a straightforward affair -
Code: Select all
<cms:pages masterpage='service_folders.php' custom_field="external_id_number==123">
    <cms:dump />
</cms:pages>

As you can see, the code is no different from that used with normal clonable templates (the extended-folder template is also one).

2. If however, you want to access the actual folder (i.e. the one belonging to the 'service.php' template), there is unfortunately no clear way (using Couch tags). The problem is that the two entities are loosely coupled only by common 'k_page title' so we'll have to amend the code above as follows -
Code: Select all
<cms:pages masterpage='service_folders.php' custom_field="external_id_number==123">
    <cms:php>global $FUNCS, $CTX; $CTX->set( 'my_folder_name', $FUNCS->get_clean_url('<cms:show k_page_title />') );</cms:php>
    <cms:if my_folder_name >
        <cms:folders masterpage='service.php' hierarchical='1' include_custom_fields='1' root=my_folder_name depth='1'>

            <cms:dump />

        </cms:folders>
    </cms:if>
</cms:pages>

Hope this helps.
Thanks KK,

I have decided to solve this problem differently. Instead of folders I now use a related template "categories".
Hi @Saskia,

I too have taken to using related templates instead of folders :) Using a catch-all "categories" template is very flexible and can be used to categorize other templates too, beyond the initial one!

One thing I wish I could do is create a new category "on the fly" while creating or editing an initial template page. For instance, if a given category doesn't exist yet and you've already started entering an initial template page's info, you have to (1) stop and save what you're doing, (2) go to the Categories tab to make a new category, (3) go back to the initial template's page, and then finally (4) select the new category.

Have you run into this issue yourself? Or have any thoughts?
4 posts Page 1 of 1