Surendra Sharma

Surendra Sharma

Search This Blog

Wednesday, June 5, 2013

Image Gallery in Sitecore

Assign Placeholder in Template Standard value and set its properties – width, height, presentation, media folder [set parent folder so that all folder images will be fall under it.]
Remember that Image Gallery accepts images of the type .JPG, all others will at the moment just result in a grey screen. If you want to include all types of images then change below lines in “ImageGalleryXMLConfiguration.xslt” file


  <!--<xsl:if test="./item[@template='jpeg']">-->
  <xsl:if test="./item">
    <album title="{@name}"
           description="{sc:fld('description',.)}"
           image="{sc:fld('image',.,'src')}">
      <!--<xsl:for-each select="item[@template='jpeg']">-->
      <xsl:for-each select="item">

Create and fill table in SQL server from XML file

<?xml version="1.0" encoding="UTF-8" ?>
<Dealers>
  <Dealer id='77'>
    <Dealer_Address>
      <Name>Action Kia</Name>
      <Address>Cnr Bruce Highway And Oak St</Address>
      <Suburb>Gympie</Suburb>
      <State>QLD</State>
      <Postcode>4570</Postcode>
      <WorkPhone>(07) 5482 2759</WorkPhone>
      <Opening_Hour>Mon-Fri: 8:00 AM-6:00 PM-br-Sat: 8:00 AM-12:00 PM-br-Sun: Closed</Opening_Hour>
      <Fax>(07) 5482 2389</Fax>
      <Url>www.actionautogroup.com.au</Url>
      <Email></Email>
      <Longitude>152.650454</Longitude>
      <Latitude>-26.179577</Latitude>
    </Dealer_Address>
    <Service_Address>
      <Name>Action Kia</Name>
      <Address>Cnr Bruce Highway And Oak St</Address>
      <Suburb>Gympie</Suburb>
      <State>QLD</State>
      <Postcode>4570</Postcode>
      <WorkPhone>(07) 5482 2759</WorkPhone>
      <Opening_Hour>Mon-Fri: 8:00 AM-6:00 PM-br-Sat: 8:00 AM-12:00 PM-br-Sun: Closed</Opening_Hour>
    </Service_Address>
  </Dealer>
  <Dealer id='7'>
    <Dealer_Address>
      <Name>Adtrans Kia</Name>
      <Address>1178 - 1184 South Road</Address>
      <Suburb>Clovelly Park</Suburb>
      <State>SA</State>
      <Postcode>5042</Postcode>
      <WorkPhone>(08) 8374 2744</WorkPhone>
      <Opening_Hour></Opening_Hour>
      <Fax>(08) 8374 2755</Fax>
      <Url>www.adtranskia.com.au</Url>
      <Email></Email>
      <Longitude>138.574837</Longitude>
      <Latitude>-34.997404</Latitude>
    </Dealer_Address>
    <Service_Address>
      <Name>Adtrans Kia</Name>
      <Address>1178 - 1184 South Road</Address>
      <Suburb>Clovelly Park</Suburb>
      <State>SA</State>
      <Postcode>5042</Postcode>
      <WorkPhone>(08) 8374 2744</WorkPhone>
      <Opening_Hour></Opening_Hour>
    </Service_Address>
  </Dealer>
</Dealers>

SELECT
      product.value('../@id', 'int') as id,
      replace(X.product.query('Name').value('.', 'VARCHAR(300)'), 'And', '&') as Name,
      X.product.query('Address').value('.', 'VARCHAR(300)')as Address,
      X.product.query('Suburb').value('.', 'VARCHAR(300)')as Suburb,
      X.product.query('State').value('.', 'VARCHAR(300)') as State,
      X.product.query('Postcode').value('.', 'VARCHAR(30)') as Postcode,
      X.product.query('WorkPhone').value('.', 'VARCHAR(20)') as WorkPhone,
      replace(X.product.query('Opening_Hour').value('.', 'VARCHAR(300)'), '-br','<br>') as Opening_Hour
INTO Service_Address
FROM
(
      SELECT CAST(x AS XML) FROM OPENROWSET(BULK 'D:\dealers_2012125 - Copy.xml', SINGLE_BLOB) AS T(x)
) AS T(x)

CROSS APPLY x.nodes('Dealers/Dealer/Service_Address') AS X(product);

Photoshop useful commands

Select – Control + Mouse click
Copy – Control + shift + C
New - Control N
Save as image size – control + shift + alt + S
Enlarge - Control + space + mouse click

Deselect all items – Control + D

Add particular child to parent in content.

Select Parent template and click on “Assign” and choose the child template. Click on Ok

Add sitecore reference in web.config file so that we can get intelligence in aspx files

<pages validateRequest="false">
      <controls>
        <add tagPrefix="sc" namespace="Sitecore.Web.UI.WebControls" assembly="Sitecore.Kernel" />
</controls>

</pages>

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="http://www.w3.org/1999/XSL/Transform" xmlns:sc="http://www.sitecore.net/sc" xmlns:dot="http://www.sitecore.net/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>-->
    <table>
      <tr>
        <td>Model Name</td>
        <td><sc:text field="ModelName"></sc:text></td>
      </tr>
      <tr>
        <td>Model Number</td>
        <td><sc:text field="ModelNumber"></sc:text></td>
      </tr>
      <tr><td>Model Image</td>
        <td>
          <sc:image Alt="Car" Width="100px" Height="100px" MaxWidth="500" MaxHeight="500" field="ModelImage"> </sc:image>
        </td>
      </tr>
    </table>
  </xsl:template>
</xsl:stylesheet>


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.

Map SiteCore Layout with Visual Studio


·         Create Template for movie 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” tags as
o    <sc:Text ID="ProductName" Field="ProductName" runat="server"></sc:Text>
o    <sc:Image ID="ProductImage" Alt="Car" Width="100px" Height="100px" MaxWidth="500" MaxHeight="500" Field="ProductImage" runat="server" ></sc:Image>
·         Build VS project.

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