Generating, Editing or previewing the SitePublisher page?

Posted: 23 July 2009 in Components, Pages, SitePublisher, Sites, XSL
Tags: , , , ,

There are times you want ot figure out if you are generating the page, editing it or previewing it. The difference for example might be useful to replace some output with a server side include directive or outputing the in-context-edit span only when we are in in-context-edit mode.

There are properties that we can look at within our components to identify our context. When you’re editing the component, preview it in order to show the resulting XML document that appearance XSL will process. Towards the top, /Properties/@Admin is set to true. When that is the case, we’re inside the teamsite/SitePublisher environment, e.g. we’re either previewing or editing the page  or the component. When it’s not set, we’re generating the page.

<xsl:choose>
<xsl:when test="not(/Properties/@Admin)">
   ...   not previewing ...
</xsl:when>
<xsl:when test="/Properties/@Admin = 'true'">
   ...   editing or previewing ...
</xsl:when>
</xsl:choose>

For a page in in-context edit with the spans and a generated page without them, use the following:

<xsl:choose>
    <xsl:when test="not(/Properties/@Admin)">
        <xsl:value-of select="article/title" />
    </xsl:when>
    <xsl:when test="/Properties/@Admin = 'true'">
        <span in-context-edit="{/Properties/Data/Datum[@ID='article']/@ID}" dcr-item-paths="/article/title"><xsl:value-of select="article/title" /></span>
    </xsl:when>
</xsl:choose>


Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s