Joomla: addStyleDeclaration inserts commented styles
My Joomla article uses Jumi to include a php file.
The php file uses $document->addStyleDeclaration
It all seems to work, except that the added style is commented out by the method! The new style is surrounded by HTML comments.
Joomla 1.5.21. Suggestions appreciated!
php file:
<?php
defined('_JEXEC') or die( "Direct Access Is Not Allowed" );
$style = <<<FOOBAR
@import url("http://foo.css");
.gfg-entry {height: 6.9em;}
#feed-control {width : 500px; padding : 10px;}
FOOBAR;
$document =& JFactory::getDocument();
$document->addStyleDeclaration ($style);
?>
Below, what is getting add开发者_Python百科ed to the page's Head section. Note the added <!-- and --> comments bracketing:
<style type="text/css">
<!--
@import url("http://foo.css");
.gfg-entry {height: 6.9em;}
#feed-control {width : 500px; padding : 10px;}
-->
</style>
Oops, it's a feature, not a bug. Joomla inserts the <!-- and --> to make the resulting page pristine XHTML.
The browser ignores HTML-style comments within style tags. Style tags use /* for comments */
精彩评论