system tag as HTML body attribute

stulk's Avatar

stulk

10 May, 2010 08:14 PM

Is there a way to set up a system region tag that would act as a template's id attribute? And if so, what kind of block should that system region tag reference XHTML, text, etc.?

Thanks.

  1. Support Staff 1 Posted by Tim on 10 May, 2010 08:52 PM

    Tim's Avatar

    There aren't any system region tags that will enable you to do this, but you could potentially add or modify the id attribute of the <body> tag by attaching a Format at the Template, Configuration Set, or Page level.

    For example, try something like this:
    * Create a new XSLT Format with code like this:

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <xsl:template match="/*">
            <xsl:copy>
                <xsl:apply-templates/>
                <xsl:copy-of select="@*"/>
            </xsl:copy>
        </xsl:template>
        <xsl:template match="node()[name()='body']">
            <xsl:copy>
                <xsl:attribute name="id">idGoesHere</xsl:attribute> <!--id goes here -->
                <xsl:copy-of select="@*"/>
                <xsl:copy-of select="./node()"/>
            </xsl:copy>
        </xsl:template>
        <xsl:template match="*">
            <xsl:copy-of select="."/>
        </xsl:template>
    </xsl:stylesheet>
    
    • Edit your Template, click the Regions pane, then select this Format for the very first field (labeled XSLT Format). Attaching the Format here (as opposed to in a specific region) will make the Format transform the fully rendered page. This is how you are able to access the <body> tag.

    The sample XSLT Format I included above will change <body> to <body id="idGoesHere">. For now, this is a static id that is hard-coded into the XSLT Format. You could, however, have something set up to where this Format would look for a specific element on the page and change the id depending on the value of that element.

    Hope this helps!

  2. Tim closed this discussion on 10 May, 2010 08:52 PM.

  3. stulk re-opened this discussion on 11 May, 2010 07:37 PM

  4. 2 Posted by stulk on 11 May, 2010 07:37 PM

    stulk's Avatar

    Thank you very much!

  5. Support Staff 3 Posted by Tim on 11 May, 2010 07:55 PM

    Tim's Avatar

    No problem!

  6. Tim closed this discussion on 11 May, 2010 07:55 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac