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 -
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
Addendum:
A variation of this method to create columns of DIVs - viewtopic.php?p=22909#p22909
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> </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