Plugin 'css' event hook

Found a bug? Tell us!!
Post Reply
judebert
Regular
Posts: 2478
Joined: Sat Oct 15, 2005 6:57 am
Location: Orlando, FL
Contact:

Plugin 'css' event hook

Post by judebert »

I'm still working on that newsbox plugin (like 10 minutes every night :( ) and I've discovered something interesting about the 'css' event hook. The plugin is stackable; I've got two enabled. When each of them gets the css hook, it checks for "newsbox" anywhere in $eventData, and adds CSS if it doesn't exist. But the CSS is getting added twice.

My first attempt just broke out of php and contained the CSS, just like in Garvin's examples. My most recent attempt actually modifies the $eventData variable, because I figure it's a reference, so it should be modified by the time the second plugin gets to it. But Nooooo...

Here's an example:

Code: Select all

                case 'css':
                    if (strpos('newsbox', $eventData) !== false)
                    {
                      // This CSS is already newsbox-aware.
                      return true;
                    }
                    $eventData = $eventData . '
.newsbox
{
  border: 1px solid black;
  padding: 2px;
  margin-bottom: 4px;
}
.newsbox_container
{
  border: 1px solid black;
  padding: 2px;
  margin-bottom: 4px;
  text-align: center;
  margin: 2px auto;
}
.newsbox_container .newsbox
{
  border: none;
  width: 48%;
  float: left;
  text-align: left;
  margin: 2px;
  display: inline;
}
                    ';
                    return true;
                    break;
I've also tried using stristr(), and checking $addData instead of $eventData. Still getting added on twice. What the heck? :?:

Still using 0.9, PHP 4.4.1. I swear I installed 0.9.1, but that's what my admin screen says.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Plugin 'css' event hook

Post by garvinhicking »

A classical problem of haystack vs. needle PHP documentation.

Replace this:

Code: Select all

                    if (strpos('newsbox', $eventData) !== false)
with this:

Code: Select all

                    if (strpos($eventData, 'newsbox') !== false)
:)

Where in the code did you find the example above? Then I could fix that.

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 »

Oh, blush. :oops:

I can't remember what I copied the thing from; probably the static pages plugin. I'll see if I can figure it out when I get home today.

But I know I searched the forums. That might be where I copied it from, and in that case it would've been easy for me to have performed the transposition.

Ooh, ooh, no, it's you! :wink:

http://www.s9y.org/forums/viewtopic.php ... ntdata+css
http://www.s9y.org/forums/viewtopic.php ... ntdata+css

I'm so relieved. I'm usually pretty anal about these things, but I do get confused after the 30th iteration or so.
Post Reply