Hi,
When i use $doc->getHeadData(); or $this->getHeadData(); in the head of the main index file in a template. There are no StyleSheets in the headData array.
The StylesSheets are only visible when i print the output from getHeadData at the end of the file.
So its looks like the modules needs to be rendered first before you can display the css files in the getHeadData().
.
.
Joomla 3.5.1
PHP 5.6.22
Because of how PHP works and how the template is parsed out, that's to be expected. So what basically happens is the template file is included into memory (doing that parses/executes the file, so at that inclusion point is when the PHP code in the template file is executed) and its string contents stored into the JDocument
object's memory. The string contents are then parsed to locate the various <jdoc>
tags and their data is parsed so the JDocument
object knows how to process that, then the various sections are parsed/rendered/executed.
So JDocumentHtml::getHeadData()
isn't something you can rely on to have the full document head until the <jdoc:include type="head" />
tag is converted into the expected HTML format. If you need to do something with that data, your best bet is a system plugin listening to the onBeforeCompileHead
event.
Thank you both! For the fast response.
I will take a look at plugin event "onBeforeCompileHead". I need to find a way to extract the css for the current page and put them in the head.
Greets,
Stephan
Labels |
Added:
?
|
Closed
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2016-06-20 21:47:08 |
Closed_By | ⇒ | brianteeman |
That's like Joomla handles it.
If you want to get a complete set of collected HeadDatas use a system plugin with plugin event onBeforeCompileHead.
Even at the end of the template index.php you cannot be sure to get all head datas of all involved extensions.