[Pmwiki-users] Re: Request for a callback once stdconfig.php has been included

Christian Ridderström chr
Fri Feb 13 21:20:22 CST 2004


On Fri, 13 Feb 2004, Patrick R. Michaud wrote:

> False!  If you want to do things after stdconfig.php, then just do the
> following in local.php:
> 
>     <?php
>       # stuff you want done before stdconfig
> 
>       include_once("scripts/stdconfig.php");
> 
>       # stuff you want done after stdconfig
> 
>     ?>
> 
Well, that's the *easy* solution ;-)  (which I didn't think of).

A serious question though. If I manually include stdconfig.php from
config.php, then this code will not have been executed before that:

	SDV($DefaultPage,"$DefaultGroup/$DefaultTitle");
	if ($pagename=='') $pagename=$DefaultPage;

I thought about this before, and it's bit like a chicken-and-hen problem

* $pagename is maybe needed by modules from config.php and stdconfig.php
* $DefaultPage is often defined in config.php
* default value of $pagename depends on $DefaultPage

One possible solution would be to use a function SetDefaultPage():

	function SetDefaultPage($group, $title) {
	  global $DefaultPage, $DefaultGroup, $DefaultTitle, $pagename;
	  $DefaultGroup=$group;
	  $DefaultTitle=$title;
	  $DefaultPage="$DefaultGroup/$DefaultTitle";
	  if (''==$pagename) $pagename=$DefaultPage;
        }

and you call this function from config.php when you wish to set the
default title and group. One advantage is that this will automatically
give $pagename a default value if that's necessary, and another advantage
is that we have consistency between $...Page, $...Title and $...Group
(assuming that's desirable of course).


> And if you really want your config file to be called "config.php", 
> then just create the following local.php:
> 
>     <?php
>       include_once("local/config.php");
>     ?>
That's the solution I'm using right now.

/Christian

-- 
Christian Ridderstr?m                           http://www.md.kth.se/~chr





More information about the pmwiki-users mailing list