Remove Style/Script from a component/module

281 views
Skip to first unread message

Viktor Iwan

unread,
Aug 19, 2012, 1:28:48 AM8/19/12
to joomla-de...@googlegroups.com
Hello all, i try to remove some script/style in head document from a module/component..
i'm using this code:

$doc = JFactory::getDocument();
$headData=$doc->getHeadData();
unset($headData['styleSheets'][JURI::base(true).'/libraries/cck/rendering/assets/css/content.css']);

when i trace, the array unset successfully, but the style still echo in the document ...

any idea how to make it work ?

Chris Davenport

unread,
Aug 19, 2012, 3:31:10 AM8/19/12
to joomla-de...@googlegroups.com
Did you do a $doc->setHeadData( $headData ); afterwards?

Chris.



--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To view this discussion on the web, visit https://groups.google.com/d/msg/joomla-dev-general/-/v_UkAYN3ALIJ.
To post to this group, send an email to joomla-de...@googlegroups.com.
To unsubscribe from this group, send email to joomla-dev-gene...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/joomla-dev-general?hl=en-GB.



--
Chris Davenport
Joomla Production Leadership Team

Viktor Iwan

unread,
Aug 19, 2012, 11:20:47 PM8/19/12
to joomla-de...@googlegroups.com
Hi Chris, it did works ! but only when i remove a single array, if i did this:

$doc = JFactory::getDocument();
$headData=$doc->getHeadData();
unset($headData['styleSheets'][JURI::base(true).'/libraries/cck/rendering/assets/css/content.css']);
unset($headData['styleSheets'][JURI::base(true).'/libraries/cck/rendering/assets/css/cck.css']);
unset($headData['scripts'][JURI::base(true).'/media/cck/scripts/jquery/js/jquery-more.js']);
$doc->setHeadData( $headData );

it won't work... any idea ?


Pada Minggu, 19 Agustus 2012 14:31:10 UTC+7, Chris Davenport menulis:
Did you do a $doc->setHeadData( $headData ); afterwards?

Chris.


On 19 August 2012 06:28, Viktor Iwan <vic...@doxadigital.com> wrote:
Hello all, i try to remove some script/style in head document from a module/component..
i'm using this code:

$doc = JFactory::getDocument();
$headData=$doc->getHeadData();
unset($headData['styleSheets'][JURI::base(true).'/libraries/cck/rendering/assets/css/content.css']);

when i trace, the array unset successfully, but the style still echo in the document ...

any idea how to make it work ?

--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To view this discussion on the web, visit https://groups.google.com/d/msg/joomla-dev-general/-/v_UkAYN3ALIJ.
To post to this group, send an email to joomla-de...@googlegroups.com.
To unsubscribe from this group, send email to joomla-dev-general+unsub...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/joomla-dev-general?hl=en-GB.

Viktor Iwan

unread,
Aug 20, 2012, 1:18:38 AM8/20/12
to joomla-de...@googlegroups.com
It fixed when i create plugin and put it on event onBeforeRender().
Reply all
Reply to author
Forward
0 new messages