Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Peter Duncanson 430 posts 1360 karma points c-trib
    Mar 01, 2010 @ 11:32
    Peter Duncanson
    0

    body tag id's where best to put them in the back end?

    Ok so we want to change the body tag id depending on which page we are on.

    This raised a couple of solutions with pros/cons:

    * Add a field to the page's data type which holds the id name, simple but users have access to it and could mess up the site. Is there a way to hide some fields only for admins?

    * Have a new master page section just for the body id, over kill really but at least only admins/developers could mess with it

    * Work out the id based on the currently template/data type. Not all the pages have CSS id friendly names so we could need a way of converting it to a machine readable name (eg convert "About us" to "about_us" or similar) which is doable but a pain and its possible for it to go wrong if someone changes a name of a template/data type

    * Simply have a XSL choose statement in a macro that adds in the id depending on some logic regarding current template, similar to above but hard coded logic in one place.

    Any one got any pointers?

     

  • Jonas Eriksson 930 posts 1825 karma points
    Mar 01, 2010 @ 11:42
    Jonas Eriksson
    0

    Hi Peter,

    I would add a property, and try to hide it for most users. One way just by placing it on an "advanced" tab, better way to use the "disabled properties" package http://our.umbraco.org/projects/axendo-disabled-properties

    I guess it would be good to also use standard properties. http://our.umbraco.org/projects/standard-values-in-umbraco

    Regards

    Jonas

  • Ian Huntington 23 posts 53 karma points
    Mar 01, 2010 @ 13:44
    Ian Huntington
    0

    Hi Peter,

    I created an XSLT which takes the section node name and replaces the spaces with a hyphen. It may not be the best solution but it was a simple solution for the site I built:

    <xsl:variable name="GetPageName" select="$currentPage/ancestor-or-self::node[@level=2]" />
    <xsl:variable name="BodyClass" select="Exslt.ExsltStrings:replace($GetPageName/@nodeName, ' ', '-')" />

    <xsl:template match="/">
        <xsl:choose>
          <xsl:when test="$currentPage/ancestor-or-self::node [@level = 2]">class="<xsl:value-of select="Exslt.ExsltStrings:lowercase($BodyClass)" />"</xsl:when>
          <xsl:when test="$currentPage/ancestor-or-self::node [@level = 1]">class="home"</xsl:when>
          <xsl:otherwise>class="default"</xsl:otherwise>
        </xsl:choose>
    </xsl:template>

    Hope that helps.

    Ian

Please Sign in or register to post replies

Write your reply to:

Draft