Filter news by current month

Discuss news styles, css code, and other Coranto customizations in here...the possibilities are endless, so have at it!

Moderator: Spunkmeyer

Filter news by current month

Postby MariahC » Tue May 11, 2004 2:29 am

I want my news to be filtered not by a set number of days or items, but by the Month. For instance, if it is May 5 and I have made 5 posts, 5 posts will show up. On May 20 if I made 20 posts, all 20 of the month will show up. On June 1, I want only the 1 post made that day to show up.

is this possible?
MariahC
 
Posts: 19
Joined: Wed Jun 26, 2002 3:24 pm

Postby Parahead » Tue May 11, 2004 7:58 am

This is a modified version of the solution provided in this thread... Place the code below at the top of your style:
Code: Select all
<PerlCode>
$CurrentMonth = (localtime(time))[4];
next unless ($CurrentMonth == $Month);
</PerlCode>
Yes, I am still around...
www.parahead.com/coranto/
User avatar
Parahead
 
Posts: 4837
Joined: Fri Jan 12, 2007 8:54 pm
Location: Stockholm - Sweden

Postby jayo » Thu Feb 10, 2005 12:03 am

Parahead wrote:This is a modified version of the solution provided in this thread... Place the code below at the top of your style:
Code: Select all
<PerlCode>
$CurrentMonth = (localtime(time))[4];
next unless ($CurrentMonth == $Month);
</PerlCode>


this works! But is there a way to only display the items for a specific month of a story..

Say Im viewing a story that was in Nov of 2004, and I have the headlines on the side of that for that month. Is there a way to make it only show the headlines for that specific month, for every story.

The code above shows it for the CURRENT MONTH. I hope i explained this right.
kinda like this:
http://www.allhiphop.com/hiphopnews/?ID=4057
No need for a SIG!
jayo
 
Posts: 104
Joined: Tue Mar 18, 2003 9:38 pm
Location: Los Angeles

Postby Parahead » Sat Feb 12, 2005 2:40 pm

jayo wrote:
Parahead wrote:This is a modified version of the solution provided in this thread... Place the code below at the top of your style:
Code: Select all
<PerlCode>
$CurrentMonth = (localtime(time))[4];
next unless ($CurrentMonth == $Month);
</PerlCode>


this works! But is there a way to only display the items for a specific month of a story..

Say Im viewing a story that was in Nov of 2004, and I have the headlines on the side of that for that month. Is there a way to make it only show the headlines for that specific month, for every story.

The code above shows it for the CURRENT MONTH. I hope i explained this right.
kinda like this:
http://www.allhiphop.com/hiphopnews/?ID=4057
I would say that this would require a little different approach. Currently you can specify Category, Style and Template to show with viewnews.cgi, but you also need to submit a newsid. If using the Random News as a base for a new addon where you could specify a month number instead you would be able to produce the sidebar on the fly.

:idea: The suggestion to be able to specify a start/end period when showing newsitems through viewnews.cgi pops up from time to time, anyone up for it?

The other solution would be to create a Maginot Sliced Profile and slice on Year/Month and then include the appropriate file based on the year/month for the newsitem you are in. I would suggest placing a SSI include command in the style for the main event, something like this:
Code: Select all
<!--#include virtual="/path/to/newsitems/<Field: Year>/<Field: Month>.shtml" -->
Yes, I am still around...
www.parahead.com/coranto/
User avatar
Parahead
 
Posts: 4837
Joined: Fri Jan 12, 2007 8:54 pm
Location: Stockholm - Sweden

Postby jayo » Sat Feb 12, 2005 8:14 pm

Parahead wrote:
jayo wrote:
Parahead wrote:This is a modified version of the solution provided in this thread... Place the code below at the top of your style:
Code: Select all
<PerlCode>
$CurrentMonth = (localtime(time))[4];
next unless ($CurrentMonth == $Month);
</PerlCode>


this works! But is there a way to only display the items for a specific month of a story..

Say Im viewing a story that was in Nov of 2004, and I have the headlines on the side of that for that month. Is there a way to make it only show the headlines for that specific month, for every story.

The code above shows it for the CURRENT MONTH. I hope i explained this right.
kinda like this:
http://www.allhiphop.com/hiphopnews/?ID=4057
I would say that this would require a little different approach. Currently you can specify Category, Style and Template to show with viewnews.cgi, but you also need to submit a newsid. If using the Random News as a base for a new addon where you could specify a month number instead you would be able to produce the sidebar on the fly.

:idea: The suggestion to be able to specify a start/end period when showing newsitems through viewnews.cgi pops up from time to time, anyone up for it?

The other solution would be to create a Maginot Sliced Profile and slice on Year/Month and then include the appropriate file based on the year/month for the newsitem you are in. I would suggest placing a SSI include command in the style for the main event, something like this:
Code: Select all
<!--#include virtual="/path/to/newsitems/<Field: Year>/<Field: Month>.shtml" -->


That worke perfect!! One last question..
How would I make the little form
That chooses a Month, and a year then go to the last story for that month..

Like it has on that allhiphop.com page
No need for a SIG!
jayo
 
Posts: 104
Joined: Tue Mar 18, 2003 9:38 pm
Location: Los Angeles

Postby Parahead » Sat Feb 12, 2005 8:30 pm

jayo wrote:That worke perfect!! One last question..
How would I make the little form
That chooses a Month, and a year then go to the last story for that month..

Like it has on that allhiphop.com page
I don´t have an out of the box solution for that one. Could either be done through JavaScript, using the onSubmit event handler and check the dropdowns and construct a URL based on those, then set the window.url or something like that. Otherwise you could construct a Perl/PHP/whatever-script that you can pass the form to which in turn handles the year/month params sent to it and loads the correct page.
Yes, I am still around...
www.parahead.com/coranto/
User avatar
Parahead
 
Posts: 4837
Joined: Fri Jan 12, 2007 8:54 pm
Location: Stockholm - Sweden

Postby jayo » Sat Feb 12, 2005 8:36 pm

Parahead wrote:
jayo wrote:That worke perfect!! One last question..
How would I make the little form
That chooses a Month, and a year then go to the last story for that month..

Like it has on that allhiphop.com page
I don´t have an out of the box solution for that one. Could either be done through JavaScript, using the onSubmit event handler and check the dropdowns and construct a URL based on those, then set the window.url or something like that. Otherwise you could construct a Perl/PHP/whatever-script that you can pass the form to which in turn handles the year/month params sent to it and loads the correct page.


Sorry Im not too knowledgeable when its comes to terms.. For Javascript, how would I do that.. Do you know?
No need for a SIG!
jayo
 
Posts: 104
Joined: Tue Mar 18, 2003 9:38 pm
Location: Los Angeles

Postby Parahead » Sun Feb 13, 2005 8:17 am

jayo wrote:Sorry Im not too knowledgeable when its comes to terms.. For Javascript, how would I do that.. Do you know?
Yes:
Parahead wrote:using the onSubmit event handler and check the dropdowns and construct a URL based on those, then set the window.url or something like that.
I will not code it for you though, if that is what you really asks...
Yes, I am still around...
www.parahead.com/coranto/
User avatar
Parahead
 
Posts: 4837
Joined: Fri Jan 12, 2007 8:54 pm
Location: Stockholm - Sweden

Postby jayo » Tue Feb 22, 2005 9:04 am

Parahead wrote:
jayo wrote:Sorry Im not too knowledgeable when its comes to terms.. For Javascript, how would I do that.. Do you know?
Yes:
Parahead wrote:using the onSubmit event handler and check the dropdowns and construct a URL based on those, then set the window.url or something like that.
I will not code it for you though, if that is what you really asks...


Cool, thanks for your time anyway, I can code this kinda stuff! :D
No need for a SIG!
jayo
 
Posts: 104
Joined: Tue Mar 18, 2003 9:38 pm
Location: Los Angeles

Postby shanemckiness » Fri Aug 12, 2005 6:58 am

Code: Select all
<PerlCode>
$CurrentMonth = (localtime(time))[4];
next unless ($CurrentMonth == $Month);
</PerlCode>


Parahead, how can we filter by current month AND current year... :)

Shane
shanemckiness
 
Posts: 234
Joined: Fri May 21, 2004 5:14 pm

Postby Parahead » Fri Aug 12, 2005 8:55 am

shanemckiness wrote:
Code: Select all
<PerlCode>
$CurrentMonth = (localtime(time))[4];
next unless ($CurrentMonth == $Month);
</PerlCode>

Parahead, how can we filter by current month AND current year... :)


Try this untested code:
Code: Select all
<PerlCode>
($CurrentMonth, $CurrentYear) = localtime(time)[4,5];
$CurrentYear += 1900;
next unless ( ($CurrentMonth == $Month) && ($CurrentYear == $Year) );
</PerlCode>
Yes, I am still around...
www.parahead.com/coranto/
User avatar
Parahead
 
Posts: 4837
Joined: Fri Jan 12, 2007 8:54 pm
Location: Stockholm - Sweden


Return to Customization

Who is online

Users browsing this forum: No registered users and 3 guests

cron