Coded something up in Couch in an interesting way? Have a snippet or shortcode to share? Post it here for the community to benefit.
9 posts Page 1 of 1
The listing of pages produced by the cms:pages tag is essentially a linear one. To generate a 'tabular' listing (e.g. a multi-row listing of portfolio items with each row having 5 items), we generally make use of CSS float property.

However, if it is required to output a HTML TABLE with each row being a TR and each item being a TD, we'll have to put in a bit more effort to do so. The logic, of course, would be to keep a count of the TDs outputted to add a TR at the proper location. Things are slightly complicated by the fact that pagination might be involved and that the last row might possibly have a lesser number of items than the TDs in each row (in which case we'll have to add ourselves the remaining TDs with   within them).

Following is a very generic code to output a table of any number of columns -
Code: Select all
<cms:set max_columns='5' />
<cms:pages masterpage='portfolio.php' limit='7' paginate='1'>
 
   <cms:if k_paginated_top>
      <cms:set current_column='1' />
      <table border="1">
   </cms:if>
   
   <cms:if current_column='1'>
      <tr>
   </cms:if>

   <td>
      <a href="<cms:show k_page_link />"><cms:show k_page_title /></a>
   </td>
   
   <cms:if current_column=max_columns>
      </tr>
   </cms:if>
   
   <cms:if k_paginated_bottom>
      <cms:if current_column lt max_columns>
         <cms:repeat count="<cms:sub max_columns current_column />">
            <td>&nbsp;</td>
         </cms:repeat>
         </tr>
      </cms:if>
      </table>
      <cms:paginator />
   </cms:if>
   
   <cms:incr current_column />
   <cms:if current_column gt max_columns >
      <cms:set current_column='1' />
   </cms:if>

</cms:pages>

The number of columns that the table consists of is set by the very first line above.
Almost the entire code above is reusable as it is. The only portion that will need customization would be the following where the template specific variables can be outputted with a TD
Code: Select all
   <td>
      <a href="<cms:show k_page_link />"><cms:show k_page_title /></a>
   </td>


Addendum:
A variation of this method to create columns of DIVs - viewtopic.php?p=22909#p22909
Thanks for the code.. :)
How can i display pages in alphabetical order? Is ther any possibilty?
Code: Select all
<cms:pages orderby='page_title' order='asc' >
   ...
</cms:pages>
Check out the 'orderby' and 'order' parameters in the 'pages' tag documentation: http://www.couchcms.com/docs/tags-reference/pages.html
Thanks cheesypoof .. I tried but my requirement is something different.. m using tabular form to display list by alphabetical order like pages starting with A, B, C etc.. is ther something like i can match first letter of page title and display?
@Robert

I am afraid such a listing is not possible with the current version of Couch.
However, the upcoming version has the feature of executing custom SQL queries.
This will make it possible to list pages (and potentially just about any other table in Couch) in any arbitrary manner.
I am sure we'll be able to use it to create the kind of alphabetical listing you mention.
the upcoming version has the feature of executing custom SQL queries
... sounds very interesting. Is there an approximate ETA for the next release of Couch? I'm looking forward to it ...
@potato
There has been a slight change in plans. Instead of a full blown 1.4 with user management etc., I think I'll release a minor 1.3.5 something first.
Apart from the mentioned custom SQL queries, a major feature of the release would be a very oft-requested one - the shopping cart.

I cannot promise a fixed date but I think it shouldn't take long now.
Wow! Thanks for all your hard work ... the shopping cart could really open up new avenues for people like me. Make sure you have a bit of R&R as well!
Awsum.. KK!! Will be waiting for new version :) Couch is simply Great !!
9 posts Page 1 of 1

Who is online

In total there is 1 user online :: 0 registered, 0 hidden and 1 guest
(based on users active over the past 5 minutes)

Users browsing this forum: No registered users and 1 guest

cron