sclang
sclang

Reputation: 229

Sitecore XSLT rendering

<xsl:for-each select="$home/item">


   <sc:text field= "Title"/><br/>



</xsl:for-each>

I have two templates inside Home, "about" and "start", the code above displays both data in the Title field, I would like to display only the Title field of "about",.. how can I do it?

Upvotes: 1

Views: 1792

Answers (1)

Trayek
Trayek

Reputation: 4410

There's multiple things you can do. If it's only going to be the "about" which you want to show (and not more afterwards), you can define a variable. For examples on that you can look at the top of a standard Sitecore rendering (or look at the definition of your $home variable).

<xsl:variable name="aboutItem" select="/sitecore/content/home/about" />

Then you can get the title like so:

<sc:text field= "Title" select="$aboutItem" />

Don't remember from the top of my head if the sc:text needs the select property or the item property.

[edit]
Just to give you an idea of another way it's also possible:

<xsl:for-each select="$home/item[@id='guid of your about item']">

   <sc:text field= "Title"/><br/>

</xsl:for-each>

Upvotes: 3

Related Questions