1 balupton Aug 04, 2006 18:23
3 balupton Aug 04, 2006 18:50
Well BeforeBlogDisplay was added for cookie settings, there was a reason why me and blueyed agreed to add it even though there was the SessionLoaded event..... but can't remember what it was.
4 yabba Aug 04, 2006 18:51
That still doesn't make admin a blog ;)
¥
5 balupton Aug 04, 2006 18:53
Yeh but... but... Well... BeforeDisplay sounds like a good event to me ;)
6 yabba Aug 04, 2006 18:58
that's the spirit ;)
¥
7 blueyed Aug 04, 2006 22:56
Yabba is right, of course.
So, balupton, are you requesting another hook? I don't think there's really the need for one, is it?
8 balupton Aug 05, 2006 05:48
so SessionLoaded should be used for setting cookies? If so, then what is the point of BeforeBlogDisplay again. (Ahh i remembered, so plugins can ouput their own pages).
9 blueyed Aug 05, 2006 17:28
What about AdminAfterMenuInit for setting cookies?
A general question though: why would you want to set a cookie on each admin page (like your plugin is currently doing)?!
10 balupton Aug 05, 2006 17:37
Well the event is there just so the Gallery class is loaded before any display happens. In the Gallery class's constructor it loads up the options, and saves the defaults. But the event is needed in the backoffice because when the user is browsing their posts there could be a gallery there.
11 blueyed Aug 05, 2006 18:28
If the user would be browsing a post with a gallery, wouldn't the Render* event then get called and you could/should just hook that?
It's not very effective, if the seperate Gallery object gets instantiated on every page in the backoffice.
12 balupton Aug 05, 2006 18:33
the plugin file only gets loaded when it needs to get loaded, hence why it needs a event to fire before any stuff is displayed.... Without it, it will only get loaded later in another event it uses, hence the 'header could not be modified' errors.
13 blueyed Aug 05, 2006 18:45
AdminEndHtmlHead() instantiates the object always, furthermore _every_ event which the plugin hooks, instantiates the Gallery object, because of the
require_once(dirname(__FILE__).'/_gallery.php');
at the top of the plugin file and the object creation therein.
And you seem to need an event before any output only for sending a cookie ("gallery_option_display") - I don't understand why this cookie would have to be sent everytime..?! It should just get sent if the option gets changed and that would be probably through Javascript anyway, wouldn't it?
14 balupton Aug 05, 2006 19:00
AdminEndHtmlHead() instantiates the object always, furthermore _every_ event which the plugin hooks, instantiates the Gallery object
yeh so? - eh... the _gallery.php file only gets included once, as require_once makes sure of that, it does not get included multiple times.... if thats what you meant...
And you seem to need an event before any output only for sending a cookie ("gallery_option_display") - I don't understand why this cookie would have to be sent everytime..?! It should just get sent if the option gets changed and that would be probably through Javascript anyway, wouldn't it?
The option is changed via ?option=value, and then setcookie via php.
I only really need to the cookie if the value changes, but then somehow i need the Gallery class to load without any output already started, and atm SessionLoaded is the best idea i have for doing that.
15 blueyed Aug 05, 2006 20:27
balupton wrote:
AdminEndHtmlHead() instantiates the object always, furthermore _every_ event which the plugin hooks, instantiates the Gallery object
yeh so? - eh... the _gallery.php file only gets included once, as require_once makes sure of that, it does not get included multiple times.... if thats what you meant...
No, that's not what I've meant. I've meant: if the admin displays the user list, edits settings, etc - the Gallery object should not get instantiated and there should be no cookie sent to the user - what for?
You should move the require_once for the gallery class out of the global scope of the gallery plugin file and only instantiate it, if necessary.
16 balupton Aug 05, 2006 20:35
When the user is browsing their posts in the back office in 'full post' mode, then they can change their display mode that way if one of their posts contains a gallery, as well as the need to include the stylesheets and javascripts as well.
So either way, the gallery class will always need to be loaded, unless their is a way for the gallery plugin to figure out wether it does need to fire this event this time or not.
Apart from the fact that admin isn't a blog :-
or (to save duplication of your code) :-
;)
¥