[pmwiki-users] New recipe: AuxSelect

marc gmane at auxbuss.com
Mon Jan 29 13:54:36 CST 2007


Patrick R. Michaud said...
> On Sat, Jan 27, 2007 at 04:11:34PM -0000, marc wrote:
> > 
> > I can see that populating the array via a page is useful - and I have 
> > thought about this - but the purpose of the recipe is to maintain state 
> > across pages. 
> 
> Hmm.  FWIW, to maintain state across pages I was thinking one
> would generally use something along the lines of:
> 
>     @session_start():
>     if (@$_POST[]) {
>       $_SESSION['inpstate'] = 
>         array_merge((array)@$_SESSION['inpstate'], $_POST);
>     }
>     $InputDefaults = @$_SESSION['inpstate'];

Sure, that's one way, but you've taken my comment out of context - 
purely accidentally, I'm sure. The issue is not retaining state - that's 
easy enough and that is an important function here, right enough - but 
making sure that the dropdown (in this case) is appropriately populated 
(for an arbitrary page). This is what the rest of my comment was about.

Tangentially, I also mentioned that the array values can change from 
page to page - this is what I have. It could be managed via sessions, 
but that would be an unnecessary implementation constraint and overhead, 
imo - especially when it can be done in config.php. I'm not sure that 
managing it through markup on multiple/all pages is a good way to do it, 
though.

However, I definitely think, in some cases, populating the dropdown 
options via markup has its uses, which is why I added the extra markup 
function to do just that.

> Of course, this could be made a bit more sophisticated by specifying
> the specific input controls to save state for, as opposed to the
> above which simply saves all inputs.

I just do it case by case. The objects take care of themselves.

> (But I don't see any major drawback to saving all inputs.)

I agree, I just don't do it that way. Although, I guess that there is 
the potential for name clashes. And including that sort of behaviour in 
a recipe seems a bit overzealous, since one doesn't know what else is 
coming in. 

-- 
Cheers,
Marc




More information about the pmwiki-users mailing list