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

Patrick R. Michaud pmichaud
Sat Feb 14 06:59:43 CST 2004


On Sat, Feb 14, 2004 at 05:20:09AM +0100, Christian Ridderstr?m wrote:
> 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
>
> One possible solution would be to use a function SetDefaultPage():
> [...]

Even easier will be to have stdconfig.php set the default page instead
of pmwiki.php, which I'm now doing.  Thus include_once("scripts/stdconfig.php");
will automatically set the pagename and the config.php author wouldn't 
have to worry about it.  Wish I had thought of this sooner.  :-)

Cookbook scripts that require having a pagename set should also
do
        if ($pagename=='') $pagename=$DefaultPage;

The only time this matters is when PmWiki is called without a pagename,
e.g, as ".../pmwiki/pmwiki.php" and not ".../pmwiki/pmwiki.php/Group/SomePage".

Pm

> 
> 	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
> 
> 
> 
> -- 
> Pmwiki-users mailing list
> Pmwiki-users at pmichaud.com
> http://pmichaud.com/mailman/listinfo/pmwiki-users_pmichaud.com



More information about the pmwiki-users mailing list