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

On my page I have two folders, one for own projects, and one for other projects. I would like to display these separately on my page so other projects are first then the own projects are further down on the page.

I use this code to display the cloned pages:
Code: Select all
<cms:pages masterpage='videocontent.php' limit='4' >
      <div class="workbox">
      <a href="<cms:show k_page_link />"><img src="/scripts/timthumb.php?src=<cms:show work_image_bigger />&h=110&w=220&zc=1" width="220" height="110" border="0"></a>
      <span class="aboutustext"><a href="<cms:show k_page_link />"><cms:show k_page_title /></a></span>
      <cms:excerptHTML count='20' ignore='img'><cms:show videocontent_content /></cms:excerptHTML>
      </div>   <!-- workbox end -->
</cms:pages>


I want to use this code twice, once for own projects and once for other projects. I'm probably being stupid but I was trying to add folder='other' to the cms:pages tag, but that wont work.

Any ideas how to do this?
You can use the 'pages' tag twice.
Once with the 'folder' parameter set to the other's folder
<cms:pages masterpage='videocontent.php' folder='others_folder_name' limit='4' >..</cms:pages>

and the second time with your own folder
<cms:pages masterpage='videocontent.php' folder='own_folder_name' limit='4' >..</cms:pages>

Make sure you are using the folder 'names' and not 'titles'.
Hi,

I'm doing something similar although with an extra level of complexity. I though i'd add it here as it seemed relevant.

I have a clonable template which has dynamic folders. I use these to display a list of products and also a menu by which to filter them by. The simplified current code is this:

Code: Select all
<!-- Menu -->
<ul>
    <cms:folders masterpage='products.php' orderby='weight'>
    <li><a href="<cms:show k_folder_link />" title="<cms:show k_folder_title />"><cms:show k_folder_title /></a></li>
    </cms:folders>
</ul>

<!-- Products -->
<cms:pages folder=k_folder_name>
    <cms:show k_page_title />
</cms:pages>


As you can see, I'm writing out the menu using
Code: Select all
<cms:folders masterpage='products.php' orderby='weight'>
to give control over the order of the menu and this is working fine.

However for the products (which are all displayed on a single page on the site), I want to be able to do the same thing so that when all the products are showing, products within a folder that has a lower folder weight is displayed first so that it matches the menu. In theory the code might look like this:
Code: Select all
<cms:pages orderby=k_folder_weight'>


Which would then display:
- all the products from k_folder_weight = 1
- then all the products from k_folder_weight = 2
- then all the products from k_folder_weight = 3
- etc...

Is this possible?

Thanks
Daz
@Daz,

I am afraid but I cannot see any straightforward way of achieving that.

Can you let me know the exact folder hierarchy and an estimate of the maximum number pages this section can expect to contain?
May be we could use some kind of hack if the number of pages is not too big.
Hi,

I have a template called Products which will have a variable number of dynamic folders and a variable number of products. Each product will belong to a folder and all of these folders will be at the top level. As an estimate, the number of products would be around 100 but needs to be able to accomodate a variable number.

I've attached a wireframe which shows what i'm trying to achieve just so it's clear. I've reduced the quantity of products for simplicity.

On the left hand side is the filter menu which represents the Folders i'm using and these are ordered using the orderby="weight" attribute and this is working fine.

The products on the right, i've grouped using colour coding (for illustrative purposes) so that the the products in red belong to category 1 (folder), blue to category 2 (folder) etc. When I click any of the categories, only those products will show and this also works fine

When all the products are shown, I want the products to be listed out in the same order as the menu such as is shown so that all products within category 1 are shown followed by all in category 2 then category 3 etc. At present they are ordered by the default which is date added.

Let me know if you need any more specific info. Hopefully there is a way around this.

Thanks
Daz

Attachments

I have an 'All Products' list view page that can order the products according to product price, which makes use of an editable region of type 'text'. I believe you could accomplish what you have described through a similar method.
Code: Select all
<cms:editable name='folder_weights' validator='decimal' type='text' />
...
<cms:pages orderby=folder_weights order='asc'>...</cms:pages>

Unless KK can come up with a better way of doing this, I think this is a pretty good solution. The only downside is it requires an extra editable region and requires the person adding the product to know what the weight is of a specific folder category. You could set up an editable region of type 'message' to dynamically display the folders with their specified folder weights as a guide to remedy part of the potential user-friendliness problem. Nevertheless, this method also would reduce the system's flexibility, since you would have a weight attached to a product, not a folder. If you wanted to modify the order or add a category at a later time, you would be in for quite a bit of editing. I haven't really completely thought through all the alternatives or ways to improve this method, so there very likely could be a more efficient way of accomplishing what you have described. I'll let you know if I come up with something better.

Update:
This makes it a bit more user-friendly, but the underlying flexibility issues still remain.
Create an editable region with these properties:
Code: Select all
<cms:editable name='folder_weights' opt_values='folders.html' dynamic='opt_values' type='radio' />

Create a file (folders.html) in your snippets folder with these contents:
Code: Select all
<cms:folders masterpage='products.php'><cms:show k_folder_title /> - <cms:show k_folder_weight />=<cms:show k_folder_weight /> | | </cms:folders>

The editable region uses the snippets file to generate a radio button listing of your folders within the admin panel. You would still use the same 'pages' tag from above, however you would disregard the 'text' editable region. I haven't actually tested this, so I hope it all works as I've described. :|
I think, cheesypoof has chalked out the best possible alternative.

Using an editable region to hold the weight ..
Code: Select all
<cms:editable name='folder_weights' type='text' search_type='integer' />

.. and then sorting on that editable region
Code: Select all
<cms:pages orderby=folder_weights order='asc'>...</cms:pages>

seems to be the only way.

To avoid having to manually enter the weight for every page, we can use the dynamic parameter and a bit of PHP.
We now define the region as follows
Code: Select all
<cms:editable name='folder_weights' type='text' search_type='integer' dynamic='default_data'>folders.html</cms:editable>

where we are defining that its default data is to be fetched dynamically. This will cause Couch to execute 'folders.html' (placed within the 'snippets' folder) everytime this region is shown in the admin panel.

We'll use the 'folders.html' to execute a bit of PHP that will set the value of our region with the weight of the selected folder. This is the entire content of 'folder.html' placed within 'snippets' folder
<cms:php>
if( isset($_POST['op']) && $_POST['op']=='save' ){
global $DB;
$rs = $DB->select( K_TBL_FOLDERS, array('weight'), 'id='.$DB->sanitize( $_POST['f_k_page_folder_id'] ) );
$_POST['f_folder_weights'] = ( count($rs) ) ? $rs[0]['weight'] : 0;
}
</cms:php>
1

IMP: Don't miss that '1' at the very bottom. That is the value this snippets returns.

The snippet checks if the page is being saved. If it is, it reads the value of the selected folder, runs a query to fetch the folder's weight from database and finally makes this the values of our region.

I think this should ease our task just a wee bit more.

For now, I am afraid, this is the best we can do.
For the future, I am thinking about a way to allow custom SQL queries with the 'pages' tag. Will come in handy for problems like this.
Thanks for everyone's input! I've not had time to implement yet but I'll give it a go and let you know how it works.

Thanks
Daz
Hi,

I got around to testing this today and it works well! I'd prefer not to have the extra editable region within the admin but other than that it's a really good solution and will do the trick. Thanks for all your help!

Cheers
Daz
9 posts Page 1 of 1