Plugin detection for "Is shown on startpage?" now

Creating and modifying plugins.
Post Reply
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Plugin detection for "Is shown on startpage?" now

Post by garvinhicking »

Hi all!

Currently some plugins try to autodetect if the plugin's "genpage" hook is called on the frontpage of the blog.

I now added this code-snippet to the default genpage.inc.php file of Serendipity 1.0 (nightlies) so that you can use $addData['startpage'] to see whether your plugin is called on the startpage, or not.

HTH,
Garvin
Last edited by garvinhicking on Wed May 24, 2006 2:35 pm, edited 1 time in total.
# 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/
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

I think a sidebar plugin should be able to access $GLOBALS['uri_addData']['startpage'], yes.

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/
judebert
Regular
Posts: 2478
Joined: Sat Oct 15, 2005 6:57 am
Location: Orlando, FL
Contact:

Post by judebert »

Hey, Garvin.

The frontpage detection isn't working for me. I just downloaded yesterday's nightly; when my plugin tries to detect the frontpage, it fails.

I'm accessing the page directly via the complete pretty URL. Apache redirect is on. The URL is http://judebert.com/wasted_youth/index.php -- I'm running s9y side-by-side with my existing static pages, so if I use index.html it'll load the old static page. I added debugging to print 'Front Page detected.' or 'Not Front Page!' at the bottom of the page; as you can see, genpage is being hooked twice, and it always thinks there's no front page.

Before switching, I was detecting frontpage with:

Code: Select all

            if ((!empty($args) && trim($args) == $serendipity['indexFile'])
                || isset($serendipity['GET']['adminModule'])
                || isset($serendipity['GET']['category'])
               )
...which seemed to work from every hook, but didn't detect archive or single entries. I can correct those after a bit of research, but I'd rather use the provided hook, since I don't know what else my frontpage detection might be missing.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

How does your plugin try to do the frontpage detection exactly?

Ah, nah. Forget it. There was a typo in genpage.inc.php (uriaddData instead of uri_addData). Just fixed, thank you!

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/
Post Reply