[pmwiki-users] Can custom markup in template's included page alter global variables ?

Hans design5 at softflow.co.uk
Wed Sep 10 05:52:44 CDT 2008


Wednesday, September 10, 2008, 11:16:12 AM, Jean-Fabrice [gmail] wrote:

> The issue is :
> When I use my custom markup in a wiki page, let's says MyGroup/MyPage,
> everything is ok : markup code is displayed, CSS styles and HTMLheader
> are ok.
> When I use my custom markup in a template's included page, like
> Site/PageActions, only the markup code is displayed. CSS styles are
> not ok, nor HTMLHeader.

> Am I doing things the wrong way ? My goal is to create some ajax
> helpers, displayed on each page. I need to include a few line of
> javascript code each time the helpers is displayed

The problem is, that by including your markup in  asub-page, like
PageActions or SideBar, the $HTMLHeader[] part doe snot get loaded,
as it is already loaded by the time the sub-pages are processed.

You could try and have your javascrip-t loaded not into the page HTML
head, but into the body, just above or below whatever else you are
trying to display. I have done that for some recipes with good
success.

If you want to avoid the script being loaded twice or more, you could
use something like this in your markup function:

static $cnt = 0; $cnt++;
...
if($cnt==1) ....java script code....

You can see it done in popupwindow.php:
http://www.pmwiki.org/pmwiki/uploads/Cookbook/popupwindow.php
where the popup javascript code is injected just once below the first
popup window link.

hope this helps a bit!

  ~Hans




More information about the pmwiki-users mailing list