Search

I had always wanted to do this but kept getting tripped up on the type="text/css" attribute turning my XSL instructions into text. I finally clued into the idea that I could assign the type with an xsl:attribute instruction. That way, you can import the appropriate style sheet based on a $page-type parameter:

<style>
  <xsl:attribute name="type">text/css</xsl:attribute>
  <xsl:text>@import url("</xsl:text>
  <xsl:value-of select="concat($workspace,'/assets/css/',$page-type,'.css')"/>
  <xsl:text>");</xsl:text>
</style>

Very nice!

Sweet...

That's a very cool idea. It never occurred to be to do it this way. This'll come handy in a couple of projects we've got coming up.

The student teaching the master? Hmm.

As I'm actually implementing this, I realize the code I supplied above is unnecessarily verbose. This works better:

<style>
  <xsl:attribute name="type">text/css</xsl:attribute>
  <xsl:value-of select="concat('@import url(',$root,'/symphony/assets/basic.css);')"/>
  <xsl:value-of select="concat('@import url(',$root,'/symphony/assets/admin.css);')"/>
  <xsl:value-of select="concat('@import url(',$root,'/symphony/assets/code.css);')"/>
  <xsl:value-of select="concat('@import url(',$workspace,'/assets/css/calendar.css);')"/>
</style>

I was actually referring to the clever use of page type for CSS importing. It's especially helpful in large, modular projects.

But in any case, it would be a wonderful day if you guys were all better at XSLT than I am! It'll promote the idea that XSLT isn't all that hard.

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details