Plugin 'css' event hook
Posted: Wed Nov 30, 2005 9:24 pm
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:
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.
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;
Still using 0.9, PHP 4.4.1. I swear I installed 0.9.1, but that's what my admin screen says.