[Pmwiki-users] Re: Request for method to let plugins execute code after stdconfig.php
Patrick R. Michaud
Fri Jul 16 13:52:06 CDT 2004
On Fri, Jul 16, 2004 at 08:51:16PM +0200, chr at home.se wrote:
> Yeah.. I can see that. Hmm.. hang on... wouldn't it work if early in
> pmwiki the code put all default values in an array?
Nope--having it in an array doesn't do anything special for
me. Technically all of the default values are already being placed
in an array ($GLOBALS), so this statement just reduces to
"wouldn't it work if PmWiki set all of its default values before loading
...and this assumes that all of the default values are known and static
before PmWiki loads customizations, which isn't true. Many values you
would want a script to modify are commonly dependent on variables set
in config.php, such as $ScriptUrl, $PubDirUrl, $FarmD, $PageTemplateFmt, etc.
A good example is $PageFooterFmt. A script would often like to be
able to add its own features into the default value for $PageFooterFmt,
but $PageFooterFmt is normally set within a layout template. The layout
template is chosen based on $PageTemplateFmt, and that's specified
in config.php. So, there's no robust way for me to set the default value
of $PageFooterFmt prior to local customization, because it gets its value
from the template. Indeed, the administrator might not want to have
a separate footer.
But to me, this whole notion of modifying variable defaults by using
string replacements is simply The Wrong Way To Do It. Better is to
standardize well-defined places where modules can add in their own
customizations as needed. For example, any module that needs something
output as an HTTP header simply adds an entry to $HTTPHeaders. Any
module that needs to add something to the <head> section of the output
document just adds an entry to $HTMLHeadersFmt. $EditMessageFmt is
the standard place to put messages and warnings on the edit page. And
so on. If the current hooks aren't sufficient, let's judiciously
add a few more.
> A drawback with this is of course that you can't specify the default value
> in the file where it fits in a more natural way. That might be a
> dealbreaker here.
It's not just what comes natural--there are dependencies that simply
cannot be resolved without someone knowing what's going on at a
More information about the pmwiki-users