[dokuwiki] Re: page id from javascript

Martin Tschofen wrote:
That's what I'm doing now, but I was hoping it would be already available in
the existing code...martin

I don't think its currently included in DW. If you have javascript which requires the value and you don't wish to update the template, that implies you are supplying custom JS to DW via a plugin. Following on from that you have a couple of alternatives ...

1. Use an action plugin to add "<script type=\"text/javascript\"> var ID = $ID; </script>" or "<input id=\"dw_page_id\" type=\"hidden\" value=\"$ID\" />" string via one of the output events, TPL_CONTENT_DISPLAY, TPL_ACT_RENDER & TPL_METAHEADER_OUTPUT(*).

2.  Use an action plugin to add the data to a cookie.

I think TPL_METAHEADER_OUTPUT & <script> string is probably best.
-- Chris

(*) Its conceivable, though probably quite unlikely, that a template will not call tpl_metaheaders() which would prevent TPL_METAHEADER_OUTPUT event from firing.
--
DokuWiki mailing list - more info at
http://wiki.splitbrain.org/wiki:mailinglist

Other related posts: