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

Is it best practice to list all <cms:folders name=''....etc in every template, or do we just list the ones for that page. if i list the ones only for that page, if i call for a folder not listed in that template will it still work?

If i list every folder, do i create a snippet and include it then?

thank you
Hi,

I am sorry but I don't think I could understand the question.
Could you please elaborate the point by giving some concrete examples?
Hi KK,

Sorry for wasting your time, and thanks for helping. Im creating a folders list:

<cms:folder name='bio_homes' title='BIO HOMES' />
<cms:folder name='bio_energy' title='BIO ENERGY' >
<cms:folder name='heating' title='BIO Heating' />
<cms:folder name='lighting' title='BIO Lighting' />
<cms:folder name='air' title='BIO AIR' />
<cms:folder name='frequency' title='BIO Frequency' />
</cms:folder>
<cms:folder name='bio_water' title='BIO WATER' >
<cms:folder name='house_filter' title='House Filter' >
<cms:folder name='aquasana_house' title='Aquasana Whole House Filter' />
<cms:folder name='aquasana_softner' title='Aquasana Whole House Softner ' />
<cms:folder name='aquasana_combo' title='Aquasana Whole House Combo' />
<cms:folder name='softner_filter' title='Whole House Water Softner Filter' />
</cms:folder>
<cms:folder name='reverse_osmosis' title='Reverse Osmosis' />
<cms:folder name='osmosis_basic' title='Reverse Osmosis - Basic' />
<cms:folder name='osmosis_standard' title='Reverse Osmosis - Standard' />
<cms:folder name='osmosis_advanced' title='Reverse Osmosis - Advanced' />
<cms:folder name='osmosis_extras' title='Reverse Osmosis Extra's>
</cms:folder>
<cms:folder name='portable' title='Portable Filter' />
<cms:folder name='portable_storage' title='Portable Storage' />
<cms:folder name='rain_storage' title='Rain Water Storage' />
</cms:folder>
<cms:folder name='bio_garden' title='BIO GARDEN' >
<cms:folder name='grow_system' title='BIO Grow System' />
<cms:folder name='grow_home' title='Home Growing'>
<cms:folder name='grow_allotment' title='Allotment Systems'>
<cms:folder name='grow_farm' title='Rent Farm Patch'>
</cms:folder>
<cms:folder name='seeds' title='Organic Seeds' />
<cms:folder name='plants' title='Organic Pants' />
</cms:folder>
etc....

I have read documentation, but i am still unclear if i have a compete list, that i keep in the header, so it is available on every page template, or do i put the whole list into each template or do i create a snippet and include it. further more should it be a complete list or only which folders are relevant for that page. Very sorry just trying to grasp who things work.

Thank you for your time.
Not a problem, @apeccms.

I'll try to answer from what I could gather.
Suppose you have two templates - 'blog.php' and 'portfolio.php'. Both are clonable so will have multiple pages in admin-panel.

If you were to place the folder's definition e.g.
Code: Select all
<cms:folder 'abc' />
<cms:folder 'xyz' />
only in the 'blog.php' template, you'll see that *all* cloned pages of blog.php will have *all* the defined folders (only two in our example).
Pages of template 'portfolio.php' will not show those folders because we did not place the definition in portfolio.php. If you want pages of portfolio to have the same folders, you'll have to place the same definition in portfolio.php also.

If, suppose, we cut the folder definition given above and then paste it into a snippet named 'my_folders.php' and then reference that snippet instead in blog.php as
Code: Select all
<cms:embed 'my_folders.php />
that would work *exactly* as if you had placed the definition directly within blog.php.

So, no difference if you use a snippet or place the definition directly within a template.

Does this answer helps in resolving your confusions somewhat?
Thanks KK,

Yes one part of question answered, seems like good practice to embed, in case we add a new folder then we dont need to edit every page just one. As to the second part of the question im not sure how to ask it. i guess i will find out as i play more with it.
Hi KK

been using the embed function to put the folders in as a snippet. but has not been loading up in the admin panel.

Should the the snippet open with <cms:template> xyz </cms:template>

where in the code should it be embed.

Code: Select all
<?php    include($_SERVER['DOCUMENT_ROOT'].'/aaa/cms.php' ); ?>
<!-- Template Details -->
<cms:template title='Product Small' clonable='1' commentable='0' order='101'>

<!-- Block  -->
   <cms:editable name="buylst1" label="Product One" type="group"/>
      <cms:editable
         name="buylst_img1"
         label="Image"
         type="image"
         maxlentgh="20"
         description="Please enter file name only."
         group="buylst1"
      />
      <cms:editable
         name="buylst_desc1"
         label="Product Description"
         type="text"
         maxlength="80"
         group="buylst1"
      />
   
   <cms:editable name="buylst2" label="Product Two" type="group" />
      <cms:editable name='op_buylst2' label="Optional product" opt_values='Yes=1' type='checkbox' desc='Click to activate'  group='buylst2'/>
      <cms:editable
         name="buylst_img2"
         label="Image"
         type="image"
         group="buylst2"
      />
      <cms:editable
         name="buylst_desc2"
         label="Product Description"
         type="text"
         maxlength="80"
         group="buylst2"
      />
   
</cms:template>   

<?php COUCH::invoke(); ?>
I'll try to illustrate the usage using the code you posted.

In your code, if suppose we wish to put only the second group of regions into a snippet, we need to cut that portion and paste it into a snippet (say, named 'my_snippet.html'). So following would be the *complete* contents of that snippet -
Code: Select all
<cms:editable name="buylst2" label="Product Two" type="group" />
  <cms:editable name='op_buylst2' label="Optional product" opt_values='Yes=1' type='checkbox' desc='Click to activate'  group='buylst2'/>
  <cms:editable
     name="buylst_img2"
     label="Image"
     type="image"
     group="buylst2"
  />
  <cms:editable
     name="buylst_desc2"
     label="Product Description"
     type="text"
     maxlength="80"
     group="buylst2"
  />

Next, embed the snippet in your original code as follows -
Code: Select all
<?php    include($_SERVER['DOCUMENT_ROOT'].'/aaa/cms.php' ); ?>
<!-- Template Details -->
<cms:template title='Product Small' clonable='1' commentable='0' order='101'>

<!-- Block  -->
   <cms:editable name="buylst1" label="Product One" type="group"/>
      <cms:editable
         name="buylst_img1"
         label="Image"
         type="image"
         maxlentgh="20"
         description="Please enter file name only."
         group="buylst1"
      />
      <cms:editable
         name="buylst_desc1"
         label="Product Description"
         type="text"
         maxlength="80"
         group="buylst1"
      />
   
      <cms:embed 'my_snippet.html' />   
   
</cms:template>   

<?php COUCH::invoke(); ?>

And now your code would behave exactly the way it originally did.
The point is, you can consider an 'embed' statement to virtually *expand* the contents of the snippet at the place of of its use.

You can use the same technique with other part of your code too.
Hope it helps.
Hi KK,

Great thanks.
8 posts Page 1 of 1