Modify the calendar so it uses future years

Random stuff about serendipity. Discussion, Questions, Paraphernalia.
Post Reply
lkelly
Regular
Posts: 13
Joined: Fri Jul 15, 2005 1:58 am

Modify the calendar so it uses future years

Post by lkelly »

I'm trying to set up a blog which appears to have entries posted in the future. For example, I want the calendar to show 2010 instead of 2005. Is there a quick change I can make to the underlying code to allow it to add several years to the dates and still calculate the right days of the month/days of the week?

Thanks.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Modify the calendar so it uses future years

Post by garvinhicking »

Yes, you can patch up the code.

Have a look at the file include/plugin_internal.inc.php. Look for the first class serendipity_calendar_plugin.

At around line 54 you can see this:

Code: Select all

 $serendipity['GET']['calendarZoom'] = serendipity_serverOffsetHour(time());
This is responsible for setting the default calendar range when none other is selected. Change this to:

Code: Select all

 $serendipity['GET']['calendarZoom'] = serendipity_serverOffsetHour(mktime(0,0,0,date('m'),date('d'),2010));
That will set the default time to the current day, month but in the year 2010.

HTH,
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/
lkelly
Regular
Posts: 13
Joined: Fri Jul 15, 2005 1:58 am

Post by lkelly »

OK, a follow up to this...

I can get the calendar to come up with the future year (i.e. July 2010) when the page loads, but if I post-date new entries on the admin page when creating them, they don't show up. If I enter new ones with today's date in 2005, those do show up in the 2005 archive. Anything else post-dated just vanishes.

(edit - more detail) I looked in the table "serendipity_entries" and did see the posts I'd added. The value in 'timestamp' seemed to be a bigger number than the test entry for 2005, so the data appears to be there. I just isn't returned by the code that pulls it from the database.

(second edit) Posts are definitely there, but show as "not yet published" under the admin tool. Sounds like I just need to know how to publish the future entries now.

Assuming I can get post-dated entries working, the follow up question will be can I get the default date on the new entry page changed so that it defaults to 2010 (for example).

Thanks.
gwilsonmail
Regular
Posts: 146
Joined: Tue Jul 12, 2005 9:12 pm
Location: Ottawa, Canada
Contact:

Post by gwilsonmail »

My guess is you need to set your server time to the year 2010.

your posts aren't being displayed because the server thinks it's 2005 and posts for 2010 haven't happened yet

Strangely I think it's 2005 as well ...
gw
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

The actual problem is that in the default setup Serendipity does not show future entries. This helps to create new articles which are only shown when the date has arrived.

For this to work, go to your Serendipity Configuration and set the Option "Show Entries from the future" to "true". :-)

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/
lkelly
Regular
Posts: 13
Joined: Fri Jul 15, 2005 1:58 am

Post by lkelly »

Garvin, that did the trick. I should have seen that option. Thanks so much.

Another thing - the code to hack so that the archive dates displayed on the right hand column (i.e. "July 2005" and "June 2005" etc.) are also offset from the future calendar year I'm using, instead of the present... I would assume it's in that same plugin_internal.inc.php file, just a little further down.

Final question for now is can the code be hacked so that the default time shown in the UI for adding entries is offset by several years? I haven't dug too deep into the source yet, but I imagine there's a function that returns the current time to that field. The "reset date" button does just that.

Thanks again.
Last edited by lkelly on Wed Jul 20, 2005 4:04 pm, edited 1 time in total.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Ikelly, sure:

Open your include/functions_entries.inc.php, search for the function serendipity_printEntryForm(). Then locate this line:

Code: Select all

    $hidden .= '        <input type="hidden" name="serendipity[timestamp]" value="' . (isset($entry['timestamp']) ? serendipity_serverOffsetHour($entry['timestamp']) : serendipity_serverOffsetHour(time())) . '" />' . $n;
modify this to:

Code: Select all

    $hidden .= '        <input type="hidden" name="serendipity[timestamp]" value="' . (isset($entry['timestamp']) ? serendipity_serverOffsetHour($entry['timestamp']) : serendipity_serverOffsetHour(mktime(date('H'), date('i'), 0, date('m'), date('d'), date('Y') + 10))) . '" />' . $n;
Note that time() got replaced with the mktime(...) command that uses todays input as default, but adds 10 Years to the year.

HTH,
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/
lkelly
Regular
Posts: 13
Joined: Fri Jul 15, 2005 1:58 am

Post by lkelly »

Thanks again. I did just edit my post while you were responding with another (probably simple for you) question. :)
Post Reply