Search code examples
cssxsltdiazo

How to set background-color using Diazo manifest parameter (XSL)


I need to modify some style colors using a Diazo manifest parameter.

My ideas was to do something like this:

    <after css:theme-children="html body">
        <style>
            body {
                background-color:<xsl:value-of select="$body_background_color" />;
            }
        </style>
    </after>

Which returns this error:

    runtime error, element 'variable' [190:0]
    XSLT-variable: Redefinition of variable 'tag_text'. [0:0]

I can get it to work without the variable:

    <after css:theme-children="html body">
        <style>
            body {
                background-color:red;
            }
        </style>
    </after>

And I can use the variable in a similar situation:

    <after css:theme-children="html body">
        <div style="background-color:{$body_background_color};">
            blah
        </div>
    </after>

But I can't put it all together.

Can anyone help with the error or point me toward another solution?


Solution

  • I found a solution in a Quintagroup theme at https://github.com/quintagroup/quintagroup.theme.sunrain/blob/master/quintagroup/theme/sunrain/static/tune.xml

    <after theme-children="/html/head/style">
        body {
          background-color: <xsl:value-of select="$body_background_color" />;
        }
    </after>
    

    This adds my css code to the end of an existing style tag in the header.