The original task is filling metas and title with most relevant information as of #374
. It is possible in some parts like pages, lists and forums, but won't work for standalone plugins, because header is already sent to output by the moment plugin is executed.
Previously we knew 2 possible solutions of the problem:
- Get the output buffer contents, replace HTML metas and title using regular expressions, drop the buffer and send the modified value again. Which would work, but is rubbish.
- Change script execution flow from header/body/footer to body/header/footer. Which is possible, but would affect some plugins which rely on existing flow.
I've recently come up to another solution:
- Use separate XTemplate variables in each part instead of just $t, e.g. $header, $body, $footer.
- For compatibility and less changes in core, make $t a reference to current template object.
- Call parse(MAIN) and out(MAIN) on those templates after all (i.e. in footer) in order they appear in code.
this way you can modify tags from main blocks of templates in any part of the script, be it header, body or footer. Including tags used for metas and title in header of course. Without changing normal flow of the script itself!
it will consume more RAM than it does now, because all the templates will stay in memory until released at the end. And probably some other things I haven't considered.
What do you think?