How can I make the calendar show FUTURE events?

Creating and modifying plugins.
Post Reply
Ianardo
Regular
Posts: 114
Joined: Sun Nov 28, 2004 3:02 pm
Location: Hastings, U.K.
Contact:

How can I make the calendar show FUTURE events?

Post by Ianardo »

Hi
I'm trying to set up Serendipity as a News/Events page but I have one major problem I need to solve before it goes live.

I need to publish entries about Future/Coming soon dates.
eg. A music event on 12th March 2005

Serendipity allows me to enter these posts and they show up on the Recent Entries list, but they don't show in Categories or in the Calendar!

Please take a look

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

Re: How can I make the calendar show FUTURE events?

Post by garvinhicking »

Well, that they show up in "recent entries" was more a bug in the 0.7 version, which has been fixed in 0.8 so that future entries will never show up.

It was requested by most users, that this is how it's handled - future events shall not show up.

However you could easily fix that in your code.

You can open the 'serendipity_functions.inc.php' file and search for those functions:

serendipity_fetchEntries
serendipity_fetchEntry
serendipity_searchEntries
serendipity_printArchives

Then you can just remove the parts related to "timestamp <= time()" or timestamp <= now" (not the ones with $range in it!). Additionaly, you have to open serendipity_sidebar_items.php, find the calendarclass and there make the change again.

Since I see the need for that function, I have just added a configuration directive for this to our CVS - the snapshot which will be generated today will contain it. :-)
# 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/
Ianardo
Regular
Posts: 114
Joined: Sun Nov 28, 2004 3:02 pm
Location: Hastings, U.K.
Contact:

Post by Ianardo »

Thanks very much. I'll try that now. :)

--Edit--

Right, I've changed 'serendipity/serendipity_functions.inc.php' so now the entries show up under categories and in the main blog. - Fantastic!

Now then, I can't find what to change in 'serendipity/serendipity_sidebar_items.php' so I still don't see the future events marked on the calendar.

I'm stumped. Any clues.
Cheers
Ian
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hm, you are right - I think in the old 0.7 days that part was inside serendipity_functions.inc.php - called something like "serendipity_printCalendar".

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/
Guest

Post by Guest »

Hmmm. I've found the function I think you mean: 'serendipity_drawCalendar'
but I don't know which bit to delete - without breaking anything!

Sorry to be a pain. I really don't know anything about php.
Cheers
Ian
Ianardo
Regular
Posts: 114
Joined: Sun Nov 28, 2004 3:02 pm
Location: Hastings, U.K.
Contact:

Post by Ianardo »

That was me by the way - forgot to log in! Sorry.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Yes, that was the right function.

Replace this code:

Code: Select all

    // Find out about diary entries
    $add_query   = '';
    $base_query  = '';
    if (isset($serendipity['GET']['category'])) {
        $categoryid  = serendipity_db_escape_string($serendipity['GET']['category']);

        if (is_numeric($categoryid)) {
            $base_query   = 'serendipity[category]=' . $categoryid;
            $add_query    = '&' . $base_query;
            $querystring = "SELECT timestamp
                              FROM {$serendipity['dbPrefix']}entries e,
                                   {$serendipity['dbPrefix']}category c,
                                   {$serendipity['dbPrefix']}entrycat ec
                             WHERE e.timestamp  >= $ts
                               AND e.timestamp  <= $endts
                               AND e.timestamp  <= " . time() . "
                               AND e.isdraft     = 'false'
                               AND e.id          = ec.entryid
                               AND c.categoryid  = ec.categoryid
                               AND c.category_left BETWEEN " . implode(' AND ', serendipity_fetchCategoryRange($categoryid));
        }

    if (!isset($querystring)) {
        $querystring = "SELECT timestamp
                          FROM {$serendipity['dbPrefix']}entries e
                         WHERE e.timestamp >= $ts and e.timestamp <= $endts AND e.timestamp <= " . time() . " AND e.isdraft = 'false'";
    }
with this:

Code: Select all

    // Find out about diary entries
    $add_query   = '';
    $base_query  = '';
    if (isset($serendipity['GET']['category'])) {
        $categoryid  = serendipity_db_escape_string($serendipity['GET']['category']);

        if (is_numeric($categoryid)) {
            $base_query   = 'serendipity[category]=' . $categoryid;
            $add_query    = '&' . $base_query;
            $querystring = "SELECT timestamp
                              FROM {$serendipity['dbPrefix']}entries e,
                                   {$serendipity['dbPrefix']}category c,
                                   {$serendipity['dbPrefix']}entrycat ec
                             WHERE e.timestamp  >= $ts
                               AND e.timestamp  <= $endts
                               AND e.isdraft     = 'false'
                               AND e.id          = ec.entryid
                               AND c.categoryid  = ec.categoryid
                               AND c.category_left BETWEEN " . implode(' AND ', serendipity_fetchCategoryRange($categoryid));
        }

    if (!isset($querystring)) {
        $querystring = "SELECT timestamp
                          FROM {$serendipity['dbPrefix']}entries e
                         WHERE e.timestamp >= $ts and e.timestamp <= $endts   AND e.isdraft = 'false'";
    }
Have fun :)
# 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/
Ianardo
Regular
Posts: 114
Joined: Sun Nov 28, 2004 3:02 pm
Location: Hastings, U.K.
Contact:

Post by Ianardo »

No, that doesn't work I'm afraid!
It kills the Blog totally and gives this message:
Parse error: parse error in /home/fhlinux194/h/haf.org.uk/user/htdocs/serendipity/serendipity_functions.inc.php on line 402
INCLUDE_ERROR
--edit--

By trial and error I think i've narrowed it down to this line:

Code: Select all

WHERE e.timestamp >= $ts and e.timestamp <= $endts   AND e.isdraft = 'false'"; 
Ianardo
Regular
Posts: 114
Joined: Sun Nov 28, 2004 3:02 pm
Location: Hastings, U.K.
Contact:

Post by Ianardo »

Done it!! (I think)
I edited just this line, manually:

Code: Select all

WHERE e.timestamp >= $ts and e.timestamp <= $endts AND e.isdraft = 'false'";
Seems to work fine now for future events.

The problem is - I have no idea why it works now!

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

Post by garvinhicking »

Hm, I suppose something bad happened during Copy&Paste from here? :)

Anyways, give our 0.8 Smarty-powered version a chance if you want to test how the 'future entries' is easily configurable there. ;)

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/
Ianardo
Regular
Posts: 114
Joined: Sun Nov 28, 2004 3:02 pm
Location: Hastings, U.K.
Contact:

Post by Ianardo »

Odd, isn't it!?

I tried many times to copy and paste it, but it just kept breaking!

So, I've finally got this version doing what I want and I have to get to grips with another???!!! EeK! :wink:
Post Reply