Page 1 of 1

How can I make the calendar show FUTURE events?

Posted: Sun Nov 28, 2004 3:38 pm
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.

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

Posted: Mon Nov 29, 2004 12:12 pm
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. :-)

Posted: Mon Nov 29, 2004 1:24 pm
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

Posted: Mon Nov 29, 2004 2:11 pm
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.

Posted: Mon Nov 29, 2004 2:54 pm
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

Posted: Mon Nov 29, 2004 3:04 pm
by Ianardo
That was me by the way - forgot to log in! Sorry.

Posted: Mon Nov 29, 2004 4:10 pm
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 :)

Posted: Mon Nov 29, 2004 5:40 pm
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'"; 

Posted: Mon Nov 29, 2004 6:13 pm
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

Posted: Mon Nov 29, 2004 6:26 pm
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.

Posted: Mon Nov 29, 2004 7:33 pm
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: