I’m trying to make an archives page that lists entries from a specific year if the year is in the URL, and list the entries from the current year if there isn’t a year in the URL.
So http://www.example.com/template_group/archives/ should show entries from this year (2008) and http://www.example.com/template_group/archives/2007 should show entries from 2007.
Here’s my archives template:
{if segment_3 == ""}
{embed="includes/_header" page_title="Archives"}
{if:else}
{embed="includes/_header" page_title="{segment_3} Archives"}
{/if}
{if segment_3 == ""}
<h1>Archives</h1>
{exp:weblog:entries weblog="my_weblog" dynamic="off" disable="categories|category_fields|member_data|pagination|trackbacks" year="2008"}
<ul>{date_heading display="daily"}
<li><a href="/daily/{entry_date">{entry_date format="%F %j, %Y"}</a></li>
{/date_heading}</ul>
{/exp:weblog:entries}
{if:else}
<h1>{segment_3} Archives</h1>
{exp:weblog:entries weblog="my_weblog" dynamic="off" disable="categories|category_fields|member_data|pagination|trackbacks" year="{segment_3}"}
{date_heading display="monthly"}<h2>{entry_date format="%F"}</h2><p>{/date_heading}<br />
<ul>{date_heading display="daily"}<br />
<li><a href="/daily/{entry_date">{entry_date format="%F %j, %Y"}</a></li><br />
{/date_heading}</ul><br />
{/exp:weblog:entries}</p>
<p>{/if}</p>
<p>{embed="includes/_nav"}<br />
{embed="includes/_footer"}The template works fine if there’s a year in segment 3 of the URL. If there isn’t, I get a blank screen. It was working before, but I don’t remember changing anything that should have broken it.