Page 1 of 1

Styling the archives

Posted: Mon Jun 04, 2007 7:00 pm
by dan
Hey,
i started to edit the .tpl files for the arrchives today and got stuck in the entries_archives.tpl, because i started to show the months in an different order than in the default view and without the table that existed before.
In the end it should look something like that wordpress archive. This is how i did it:

Code: Select all

{serendipity_hookPlugin hook="entries_header"}
<h2 class="serendipitysidebartitle">{$CONST.ARCHIVES}</h2>
{foreach from=$archives item="archive"}
 	{foreach from=$archive.months item="month"}
        <div class="archive_month">
        	<b>{if $month.entry_count}<a href="{$month.link}">{/if}{$month.date|@formatTime:"%B"} {$archive.year}{if $month.entry_count}</a>{/if}</b> {$month.entry_count} {$CONST.ENTRIES}
        </div><br>
         {foreach from=$entries item="entries"}
         	{foreach from=$entries.entries item="entry"}
            	<a href="{$entry.link}">{$entry.title}</a>
        	{/foreach}
    	{/foreach}
	{/foreach}
{/foreach}
<div class="serendipity_pageFooter" style="text-align: center">
{serendipity_hookPlugin hook="entries_footer"}</div>
The code past the

Code: Select all

<div class="archive month>...</div><br>
is 'stolen' form the entries_summary.tpl. I think that's the problem I got. Because anything to this point works perfect, but the entries aren't listed under the months. I really don't know why and I hope you could spend some help!
[/url]

Re: Styling the archives

Posted: Tue Jun 05, 2007 3:41 pm
by garvinhicking
Hi!

That's true, you can't do it this way.

The reason is simply that no $entries variable is available on those pages. No entries are fetched, only the amount of entries.

You CAN get a page like this, but it involves much heaver smarty usage. You will need to utilize the {serendipity_fetchPrintEntries} function for that, create a new second template for the specific output and pass the date as an option to that fetchprintentries function. This will be some work. :-)

How about patching entries_summary.tpl instead to give a format like the URL you gave as an example? Then the user would need to click on a month first to see the output, but that would mean much less work for your custom template, and you wouldn't need to dig into Smarty.

Best regards,
Garvin

Posted: Tue Jun 05, 2007 4:49 pm
by dan
Hey,
thanks for your help. That's what I thought the entry titles are only available for the entries_summary.tpl. I really don't want to dig so deep into smarty, so i'll search for another good looking solution.
thanks a lot garvin!

oder auch vielen dank^^