Page 1 of 1
News display in rows?
Posted: Sat Sep 10, 2005 5:20 pm
by Tepes
Hi.
Since I am using the news function as a product cataclogue I am wondering if there is a way to get the news to be displayed next to each other instead of underneath each other. For example three news/products in a row, then a new row with 3 products and so on.
Thanks
KEv
Re: News display in rows?
Posted: Sun Sep 11, 2005 8:53 pm
by jah
Hi,
hopefully this can help you.
Replace the Summary Template with the following:
Code: Select all
<!-- Start News Summary Template -->
{assign var="numCols" value="3"}
<table class="news_summary_table">
<tr class="news_summary_row">
{assign var="col" value="0"}
{section name=element loop=$items}
{if $col == $numCols}
</tr><tr class="news_summary_row">{assign var="col" value="0"}
{/if}
<td class="news_summary_cell">{$items[element]->summary}
{* This is the summary information for an article*}
<p>
{$items[element]->titlelink}
<br />
{$items[element]->category}
{if $items[element]->postdate}
<br />
{$items[element]->postdate|date_format}
{/if}
{if $items[element]->summary}
<br />
{$items[element]->summary}
<br />
[{$items[element]->morelink}]
{else if $items[element]->content}
<br />
{$items[element]->content}
{/if}
</p>
{* End summary information for article*}
</td>
{assign var="col" value="`$col+1`"}
{/section}
{assign var="remainder" value="`$numCols-$col`"}
{section name=emptyElement loop=$remainder}
<td class="news_summary_cell"> </td>
{/section}
</tr>
</table>
<!-- End News Summary Template -->
You can change the number of columns in the first line:
I've added classes to the table, rows and cells (news_summary_table, news_summary_row and news_summary_cell)
It is based on the following Smarty tutorial:
http://smarty.incutio.com/?page=SmartyColumnsTutorial
Jon
Re: News display in rows?
Posted: Mon Sep 12, 2005 2:57 pm
by Tepes
Looks like it works!
Thank you so very very very mucth. I really appreciate it!
KEv
Re: News display in rows?
Posted: Sun Sep 18, 2005 9:06 pm
by Tepes
Really hate to bother you guys with this. I am sure this is so unbelievably simple, but since I am no coder I am having a hard time getting the exact result I want. I have tried for a while to get it right, but thought I push my luck and ask you guys for help again.
I need to split the table in two rows. One row contains the {$items[element]->summary}, and the other row displays the {$items[element]->titlelink}. I have tried several solutions, but either one or the other doesen't show, or it spans over more than three rows.
I realise that
{if $col == $numCols}
{assign var="col" value="0"}
{/if}
terminates the row and starts a new row if the table spans over the desired number of collums. So basicly I need this to terminate and start a new row AFTER the "titlelink" row. I will keep on trying and post here if I get it right. But if someone out there can help me out it would be mutch appreciated.
KEv
Re: News display in rows?
Posted: Mon Sep 19, 2005 11:36 am
by Tepes
Well, I didn't get it right, so I just cheated by adding a new table within the old one. Only problem is if the summary expands the set height of the summary cell. Then it displaces the table.
It's not the best solution, but it works for now.
KEv