[pmwiki-users] toggle.php and HTMLFooterFmt question

Criss Ittermann crisses at kinhost.org
Thu Jul 3 16:33:00 CDT 2014


On Jul 3, 2014, at 5:01 PM, michael paulukonis <xraysmalevich at gmail.com> wrote:

> I think you're agreeing with me.
> 
> Which means that the 2014-02-21 needs to be patched.

Yes, and your idea is probably better than [] in case someone needed a var dump to debug something.  On the HTML end, the javascript comes out fine with [].

> On Thu, Jul 3, 2014 at 3:55 PM, Criss Ittermann <crisses at kinhost.org> wrote:
> 
> On Jul 1, 2014, at 12:18 PM, michael paulukonis <xraysmalevich at gmail.com> wrote:
> 
>> re: http://pmwiki.org/wiki/Cookbook/Toggle
>> 
>> In the toggle.php recipe of 2014-02-21, we see the following:
>> 
>> $HTMLFooterFmt['toggle'] = "<script type=\"text/javascript\">document.getElementById(\"{$id}\").style.display = '{$style}';</script>";
>> 
>> This should create a simple string that is places into the HTMLFooterFmt hash with the index of "toggle."
>> 
>> How on earth is toggle supposed to function if there is more than one toggle present on the page?
> 
> If you have more than one toggle, make sure they all have a different id. :)
> 
> I've used this recipe several times, and I love it.  It works very well.  When I used it with (:panelist:) for quizzes, I made sure to use a variable from the page (say $Name) as the index.
> 
> Example of a quiz at work, entirely PmWiki driven -- each quiz's info is stored in data pages elsewhere on the site, they have categories and are pulled into various pages of the website...  http://bte18.com/Main/GolfingBasics  So you can see the different calls to the toggle javascript code on the HTML end here.
> 
> 
>> Am I missing something in PHP/PmWiki that would allow this to work?
> 
> 
> It's a combo of PmWiki and Javascript at work here.  :)
> 
>> We don't see anything like this behavior in the older version from 2009-07-23
>> 
>> Perhaps not coincidentally, I have multiple toggles working with the version from 2009-07-23, but not with 2013-02-21
>> 
>> Unless I make the following change:
>> 
>>   $HTMLFooterFmt["toggle$id"] = "<script type=\"text/javascript\">document.getElementById(\"{$id}\").style.display = '{$style}';</script>";
> 
> Try the same line in the toggle.php I got from the cookbook (years ago):
> $HTMLFooterFmt[] = "<script type=\"text/javascript\">document.getElementById(\"{$id}\").style.display = '{$style}';</script>";
> 
> The moment that you name it ['toggle'] it will only make one entry in $HTMLFooterFmt.  with the [] it will just append them all to the array with numbered indexes.
> 
> If you want them indexed "toggle" then yes they need unique $id appended to 'toggle" so each index is unique... which is exactly what you said worked.
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.pmichaud.com/pipermail/pmwiki-users/attachments/20140703/b220300a/attachment-0001.html>


More information about the pmwiki-users mailing list