New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
set page context in Handler #3267
base: master
Are you sure you want to change the base?
Conversation
Under some circumstances it is useful to know if the current parsing process is running in a page context or not. One of the examples is the struct plugin's use of the PARSER_HANDLER_DONE event to automatically inject its own output instruction. Currently this instruction is injected in each and every processing and only on rendering is decided if there is anything to output. This patch injects a page hint into the Handler when the handler was created from our p_wiki_xhtml() method (and only then). Plugins can use the getPage() method to check the context if needed. Note: currently p_wiki_xhtml() also modifies the global $ID variable which might also used as context hint (but will also be set during on-the-fly renders, eg. the preview intro text). It would probably be a good idea to check if it would be better when all handle methods rely on getPage() instead of global $ID instead. This would be a major change in parsing though and needs serious testing while this addition has basically no consequences currently.
So |
Yes, that's the idea. |
|
Is there any reason why the id is not passed on in line 181 in [Edit] Iirc there are also cases where |
I have not yet looked in the details, but this looks like an other application of this: lpaulsen93/dokuwiki-plugin-odt#260 |
Under some circumstances it is useful to know if the current parsing process is running in a page context or not.
One of the examples is the struct plugin's use of the PARSER_HANDLER_DONE event to automatically inject its own output instruction. Currently this instruction is injected in each and every processing and only on rendering is decided if there is anything to output.
This patch injects a page hint into the Handler when the handler was created from our p_wiki_xhtml() method (and only then). Plugins can use the getPage() method to check the context if needed.
Note: currently p_wiki_xhtml() also modifies the global $ID variable which might also used as context hint (but will also be set during on-the-fly renders, eg. the preview intro text).
It would probably be a good idea to check if it would be better when all handle methods rely on getPage() instead of global $ID instead. This would be a major change in parsing though and needs serious testing while this addition has basically no consequences currently.