Display articles from specific year
Posted: 15 April 2008 08:02 AM   [ Ignore ]  
Summer Student
Total Posts:  19
Joined  01-29-2008

I’m currently trying to build a press release section on a website for a client. What I have so far is a template built called “press_releases” that will list all the articles. What I would like to do is use this template to then display articles from specific years, which will be specified through the url. So the urls will be like press_releases/2007/ press_releases/2006 and so on.

Is it possible for me to use this segment within the weblog entries tag to display this year. Ideally something like year=”{segment_3}” if this is possible. I have come across this - http://expressionengine.com/wiki/Yearly_Archives/

However I don’t think this is quite what I’m looking for, nor the pulgin linked to from the site. I’m sure I must be missing something very simple/easy to do but would appreciate any pointers in the right direction.

Profile
 
 
Posted: 15 April 2008 08:09 AM   [ Ignore ]   [ # 1 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  23547
Joined  05-20-2002

Will the year parameter do the trick?  Would likely need to combine with dynamic=“off”.

 Signature 

AKA rob1

Help Request TipsPro Network

Profile
 
 
Posted: 15 April 2008 08:33 AM   [ Ignore ]   [ # 2 ]  
Summer Student
Total Posts:  19
Joined  01-29-2008

Odd, I did try it and was getting errors originally but now it’s working fine. Thanks for the quick response.

Profile
 
 
Posted: 15 April 2008 08:38 AM   [ Ignore ]   [ # 3 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  23547
Joined  05-20-2002

Odd indeed.  But- glad that’s got you squared away.

 Signature 

AKA rob1

Help Request TipsPro Network

Profile
 
 
Posted: 15 April 2008 09:07 AM   [ Ignore ]   [ # 4 ]  
Summer Student
Total Posts:  19
Joined  01-29-2008

This question may be related to a resolved thread.

Sorry I just posted about this and thought it was sorted but having a small issue.

The code I have is -

{if segment_3=='' OR segment_3=="{current_time format="%Y"}"} year="{current_time format="%Y"}"{if:else} year="{segment_3}"{/if}

This seems to be working absolutely fine, almost.

If I change the url to /2008 it displays 2008, same goes for everything else apart from if segment_3 is blank. If segment_3 is blank is displays all the articles from all the years.

The URLs are as follows -
/press_centre/press_releases/ - displays everything
/press_centre/press_releases/2008 - correctly displays 2008
/press_centre/press_releases/2007 - correctly displays 2007

I must be missing something silly but have tried all sort of fun and games and can’t seem to get it playing ball if the URL is blank. This is just a precaution more then anything, but it would be nice to get sorted.

Any help would be appreciated and sorry for posting again so quickly.

Profile
 
 
Posted: 15 April 2008 09:12 AM   [ Ignore ]   [ # 5 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  23547
Joined  05-20-2002

Heh- sorry for closing it out a bit early!  OK- see if this works:

{if segment_3==''} year="{current_time format="%Y"}"{/if}{if segment_3} year="{segment_3}"{/if}


I have my doubts- but it’s worth a try.  If it doesn’t work- I personally would go with some php.

 Signature 

AKA rob1

Help Request TipsPro Network

Profile
 
 
Posted: 15 April 2008 09:16 AM   [ Ignore ]   [ # 6 ]  
Summer Student
Total Posts:  19
Joined  01-29-2008

Works a treat grin Looks as though I was trying to over complicate things a little bit too much.

Thank you!

Profile
 
 
Posted: 15 April 2008 09:33 AM   [ Ignore ]   [ # 7 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  23547
Joined  05-20-2002

Parse order can get tricky with some of the conditionals.  Glad this worked.  Now- let’s see if I can manage to merge these two threads.

 Signature 

AKA rob1

Help Request TipsPro Network

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 09:33 AM
Total Registered Members: 65087 Total Logged-in Users: 34
Total Topics: 82229 Total Anonymous Users: 20
Total Replies: 441928 Total Guests: 216
Total Posts: 524157    
Members ( View Memberlist )