Styling the archives

Skinning and designing Serendipity (CSS, HTML, Smarty)
Post Reply
dan
Regular
Posts: 5
Joined: Mon Jun 04, 2007 6:52 pm

Styling the archives

Post 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]
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Styling the archives

Post 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
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
dan
Regular
Posts: 5
Joined: Mon Jun 04, 2007 6:52 pm

Post 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^^
Post Reply