The Serendipity Handbook

You can now read the (german) handbook here: PDF - https://github.com/s9y/Book (LaTeX source).

Forum-Information

Before posting about errors, make sure that the answer cannot already be found in our FAQ or by searching this forum!
Posting is restricted to registered users (registering is free and simple!) due to recent spam attacks. When having trouble with this board, contact garvin(-at)s9y(-dot)org.

Board index Plugins serendipity_event_staticpage and error_404 (AGAIN)

Creating and modifying plugins.
gregman
Regular
 
Posts: 92
Joined: Wed Aug 15, 2007 9:32 pm

Postby gregman » Sun Apr 22, 2012 9:48 pm

Hi there,

I suggest to add

Code: Select all
$serendipity['view'] = 'plugin';
unset($serendipity['viewtype']);


after

Code: Select all
$this->error_404 = FALSE;


in serendipity_event_staticpage.

Reason: If staticpage plugin found that one page is existing, variables $serendipity['view'] and $serendipity['viewtype'] which could formerly be set by index.php to 404/404_x should be correctly adapted.

Regards
Greg

User avatar
garvinhicking
Core Developer
 
Posts: 28944
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany

Postby garvinhicking » Sun Apr 22, 2012 9:58 pm

Hi!

But actually, the 404 view would be the correct content of it; else you couldn't really query that in custom index.tpl statements...?

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/

gregman
Regular
 
Posts: 92
Joined: Wed Aug 15, 2007 9:32 pm

Postby gregman » Tue Apr 24, 2012 8:58 am

I'm sorry but this doesn't make any sense.

Serendipity's view isn't "404" any more, when there is a staticpage plugin which can handle the request. This in fact was one of the hardest issues, I had to struggle with, when I rebulit my blog system. I would wish that core and staticpage plugin work hand in hand much better.

But I also accept that there are grown structures which can't be changed so easily. As you have a much deeper sight into that than I, you will probably be right. Sadly, this means another part of the core that I have to patch manually and be aware of when upgrading.

Greg

User avatar
garvinhicking
Core Developer
 
Posts: 28944
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany

Postby garvinhicking » Tue Apr 24, 2012 9:34 pm

Hi!

But the staticpage that is being served is a 404 page...IMHO then all other s9y plugin templates shoud be able to respond to that "404" view. How else would a index.tpl or other s9y template file know that a 404 page is being served, if "view" were set to "plugin"? Then no template could distinct between "normal staticpage" and "404 staticpage".

On the other hand I see no advantage to setting it to "plugin"?

In which case do you need to query for "view=plugin", what do you want to achieve? Instead you could i.e. check for $staticpage_pagetitle if you want to check if a staticpage is used...

Regards,
Garvin

(A solution to prevent patching the core would be to create your own event plugin that is installed after the staticpage plugin, which corrects the serendipity-view in case a 404 staticpage is emitted)
# 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/

gregman
Regular
 
Posts: 92
Joined: Wed Aug 15, 2007 9:32 pm

Postby gregman » Thu Apr 26, 2012 2:07 pm

Maybe I don't understand the code right but IMHO it should be as follows:

1) index.php couldn't find a page according to the given url.

2) Now staticpage plugin looks into the permalinks table and finds a page corresponding to the given (nice) url.

3) If the found page is itself defined as 404_error_page, this->error_404 shoudl be set to TRUE and $serendipity['view'] and $serendipity['viewtype'] can stay as is.

4) Else staticpage plugin should set this->error_404 to FALSE and IMHO correct $serendipity['view'] and $serendipity['viewtype'] which was set by index.php

In PHP:

Code: Select all
foreach ($pages as $page) {
    if ($page['permalink'] == $nice_url) {
        if ($page['is_404_page']) {
            $this->error_404 = TRUE;
        } else {
            $this->error_404 = FALSE;
            $serendipity['view'] = 'plugin';
            unset($serendipity['viewtype']);
        }
        break;
    }
}



Greg

Besides: What I wonder about is, why line 2743 reads
Code: Select all
if ($pages['is_404_page']) {

not
Code: Select all
if ($page['is_404_page']) {



Return to Plugins

Who is online

Users browsing this forum: No registered users and 0 guests