modifying css based on xml content
This is an open discussion with 4 replies, filed under XSLT.
Search
No. You can define a page in Symphony as a CSS page and create CSS code. The problem at the moment is: I think that this bug is still alive. So you will have to hack /symphony/lib/toolkit/class.frontendpage.php
in order to have the right header returned.
You may add these lines in line 80 of the file:
elseif(@in_array('CSS', $this->_pageData['type']) || @in_array('css', $this->_pageData['type'])){ $this->addHeaderToPage('Content-Type', 'text/css; charset=utf-8'); } elseif(@in_array('JS', $this->_pageData['type']) || @in_array('js', $this->_pageData['type'])){ $this->addHeaderToPage('Content-Type', 'application/x-javascript; charset=utf-8'); }
Then, in your page XSL, you may do s.th. like this:
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="text" omit-xml-declaration="yes" encoding="utf-8"/> <xsl:param name="blabla"/> <xsl:variable name="blabla-2"> ... </xsl:variable> <xsl:template match="data"> <![CDATA[ #container { /* generated dynamically against url parameters */ ]]> <xsl:choose> ... </xsl:choose> <![CDATA[ /* end generated dynamically */ /* static part */ margin-bottom: 18px; color: #000; text-align: left; } ]]> </xsl:template> </xsl:stylesheet>
As you see, it is of vital interest to deal with CDATA sections properly. But it works!
I forked this extension here and added setting content-disposition to ‘attachment’ if you add a ‘.’ to the Page type. In hindsight I think this usually isn’t needed if you have the right content-type (but I guess is useful for the filename, which is set to the page’s handle + the page type). Anyway, I just sent a pull request, so Alistair will probably clean up my fix and post a new version, if you want to wait for that. Otherwise the fork at the link above should work.
Than you, ashooner!
Thanks! i don’t know enough about github and forks yet, so I go with inline styles for now and look into this later.
Create an account or sign in to comment.
Is inline css within the created html files the only way to have xml make changes to the css?