Important Notice from AspDotNetStorefront
It is with dismay that we report that we have been forced, through the action of hackers, to shut off write-access to this forum. We are keen to leave the wealth of material available to you for research. We have opened a new forum from which our community of users can seek help, support and advice from us and from each other. To post a new question to our community, please visit: http://forums.vortx.com
Results 1 to 6 of 6

Thread: Adding OpenGraph information

  1. #1
    ideal_airsoft is offline Member
    Join Date
    Nov 2007
    Posts
    43

    Default Adding OpenGraph information

    I've added a facebook like button and google +1 button to my product page. Is there any way to add the meta tags for open graph to the head section through the XML package so the information will be per product?

  2. #2
    ROBB is offline Senior Member
    Join Date
    Jun 2011
    Location
    United States
    Posts
    107

    Default OpenGraph Meta Tags

    Yes, you can reference an XML package in the head section of your template file. The referenced XML package should contain your open graph meta tags.

  3. #3
    ideal_airsoft is offline Member
    Join Date
    Nov 2007
    Posts
    43

    Default

    How will the xml package know that I'm on a product page?

  4. #4
    ROBB is offline Senior Member
    Join Date
    Jun 2011
    Location
    United States
    Posts
    107

    Default Parameters

    The XML package will be passed the product id (as a parameter), which can be used in a query to pull in the information you need.

  5. #5
    don.irwin is offline Member
    Join Date
    Apr 2006
    Location
    Phoenix AZ
    Posts
    81

    Default

    here's the xml package I use to add open graph tags to the header:

    Code:
    <?xml version="1.0" standalone="yes" ?>
    <package version="2.1" displayname="Facebook OpenGraph Tags" debug="false" includeentityhelper="false">
    
      <query name="Products" rowElementName="Product">
        <sql>
          <![CDATA[
                    SELECT ProductID, Name, SEDescription, ImageFileNameOverride, SKU FROM Product WHERE ProductID = @ProductID
                ]]>
        </sql>
        <queryparam paramname="@ProductID" paramtype="request" requestparamname="ProductID" sqlDataType="int" defvalue="0" validationpattern="^\d{1,10}$" />
      </query>
    
      <PackageTransform>
        <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                        xmlns:aspdnsf="urn:aspdnsf" exclude-result-prefixes="aspdnsf">
          <xsl:output method="xml" omit-xml-declaration="yes" />
    
          <xsl:template match="/">
    
            <!-- start of setting the canonical link for category & product pages -->
            <xsl:param name="canonical" select="concat(/root/System/StoreUrl, /root/System/PageName)" />
    
            <!-- end of setting the canonical link for category & product pages -->
    
            <!-- start of setting the image link for product pages -->
            <xsl:param name="image_link">
              <xsl:choose>
                <xsl:when test="boolean(/root/Products/Product/ProductID)">
                  <xsl:value-of select="aspdnsf:ProductImageUrl(/root/Products/Product/ProductID, /root/Products/Product/ImageFileNameOverride, /root/Products/Product/SKU, 'medium', 'true')" />
                </xsl:when>
                <xsl:otherwise>0</xsl:otherwise>
              </xsl:choose>
            </xsl:param>
            <!-- end of setting the image link for product pages -->
    
            <!-- start of setting the product name for product pages -->
            <xsl:param name="prod_name">
              <xsl:choose>
                <xsl:when test="boolean(/root/Products/Product/ProductID)">
                  <xsl:value-of select="/root/Products/Product/Name"/>
                </xsl:when>
                <xsl:otherwise>0</xsl:otherwise>
              </xsl:choose>
            </xsl:param>
            <!-- end of setting the product name for product pages -->
    
    
            <!-- use SEDescription - no HTML -->
            <xsl:variable name="FBDesc" select="/root/Products/Product/SEDescription" />
            <!-- end of setting the product description for product pages (including stripping html tags) -->
    
            <!-- start of rel canonical DELETE THIS IF YOU DON'T WANT IT -->
            <xsl:choose>
              <xsl:when test="$canonical != 0">
                <link rel="canonical" href="{$canonical}" />
              </xsl:when>
              <xsl:otherwise></xsl:otherwise>
            </xsl:choose>
            <!-- end of rel canonical DELETE THIS IF YOU DON'T WANT IT -->
    
    
            <!-- start of og tags REMEMBER TO EDIT THE ADMIN ID TO MATCH YOUR OWN AND THE SITE NAME TOO-->
            <xsl:choose>
              <xsl:when test="$image_link != 0">
                <meta property="og:title" content="{$prod_name}"/>
                <meta property="og:type" content="product"/>
                <meta property="og:image" content="{$image_link}"/>
                <meta property="og:url" content="{$canonical}"/>
                <meta property="og:description" content="{$FBDesc}"/>
                <meta property="og:site_name" content="SITE NAME"/>
                <meta property="fb:admins" content="########"/>
                <link rel="image_src" href="{$image_link}" />
              </xsl:when>
              <xsl:otherwise></xsl:otherwise>
            </xsl:choose>
            <!-- start of og tags REMEMBER TO EDIT THE ADMIN ID TO MATCH YOUR OWN AND THE SITE NAME TOO-->
    
          </xsl:template>
        </xsl:stylesheet>
      </PackageTransform>
    </package>

  6. #6
    BFG 9000 is offline Senior Member
    Join Date
    Oct 2006
    Location
    South UK
    Posts
    882

    Default

    That's a mighty fine looking xmlpackage !!


    TTFN

    BFG