Surendra Sharma

Surendra Sharma

Search This Blog

Wednesday, June 5, 2013

Map SiteCore Layout placeholder with Visual Studio

·         Create Template with standard values
·         Create Layout and relate the layout with the template from Template – Presentation – details – Default – Edit – Select layout – OK
·         Create Layout Page in Visual Studio with same name. Add “sc” placeholder tag as
o    <sc:Placeholder ID="ModelPlaceholder" Key="ModelPlaceholder" runat="server" />

·         Create XSLT in Sitecore in Layout\Renderings\Component. Specify Path as “/layouts/Renderings/Components/ModelRendering.xslt”
o   Note: - This Path must map with VS folder structure path. Check spellings.
·         Add XSLT in VS in “/layouts/Renderings/Components/ModelRendering.xslt” like
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="" xmlns:sc="" xmlns:dot=""
                exclude-result-prefixes="dot sc" >

  <xsl:output method="html" indent="yes" encoding="UTF-8"/>

  <!-- parameters -->
  <xsl:param name="lang" select="'en'"/>
  <xsl:param name="id" select="''"/>
  <xsl:param name="sc_item"/>
  <xsl:param name="sc_currentitem"/>

  <!-- entry point -->
  <xsl:template match="*">
    <!--<xsl:value-of select ="$sc_currentitem"></xsl:value-of>-->
        <td>Model Name</td>
        <td><sc:text field="ModelName"></sc:text></td>
        <td>Model Number</td>
        <td><sc:text field="ModelNumber"></sc:text></td>
      <tr><td>Model Image</td>
          <sc:image Alt="Car" Width="100px" Height="100px" MaxWidth="500" MaxHeight="500" field="ModelImage"> </sc:image>

o   Note: - Keep all tag in small letters like <sc:text as XSLT is case sensitive. While in VS you can write it as “<sc:Text”. Also remove “id” and “runat” property from XSLT.
·         Build VS project.
·         Relate the XSLT with the template from Template – Presentation – details – Default – Edit – Controls – Add – Select XSLT File – Enter Placeholder name – Select - OK – OK

·         Create Content from template. See preview either from Presentation – Preview or Publish – Preview.

No comments:

Post a Comment