?
avatar amorz
amorz
17 Jun 2016

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.

Steps to reproduce the issue

So its looks like the modules needs to be rendered first before you can display the css files in the getHeadData().

Expected result

.

Actual result

.

System information (as much as possible)

Joomla 3.5.1
PHP 5.6.22

Additional comments

avatar amorz amorz - open - 17 Jun 2016
avatar bertmert
bertmert - comment - 17 Jun 2016

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.

avatar mbabker
mbabker - comment - 17 Jun 2016

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.

avatar amorz
amorz - comment - 17 Jun 2016

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

avatar brianteeman brianteeman - change - 18 Jun 2016
Labels Added: ?
avatar brianteeman
brianteeman - comment - 20 Jun 2016

Closed


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/10856.

avatar brianteeman brianteeman - change - 20 Jun 2016
Status New Closed
Closed_Date 0000-00-00 00:00:00 2016-06-20 21:47:08
Closed_By brianteeman
avatar brianteeman brianteeman - close - 20 Jun 2016

Add a Comment

Login with GitHub to post a comment