Page 2 of 5 FirstFirst 1234 ... LastLast
Results 11 to 20 of 46

Thread: xmlpackage to add Facebook 'Like' buttons & OG tags with bonus rel-canonical support

  1. #11
    Join Date
    Dec 2010
    Posts
    72

    Default

    Any comments on this... obviously I'm missing something here because I am getting the same thing. It's just printing (!XmlPackage Name="facebook"!) at the top of the page, it's not running the xml package.

    Edit: Ok, I'm running version 9.1.0.1 and I found one issue. You can't start an XML Package the old way, (!XmlPackage Name="facebook"!). I found an article that lead me to using

    Code:
    <asp:Literal ID="lit1" runat="server" Text="<%$ Tokens:Xmlpackage, facebook.xml.config %>" />
    However, this produces nothing in the source code of the page, so something still isn't working.

    Quote Originally Posted by macecase View Post
    Thanks for sharing. I am getting an error.

    The log shows two errors when trying to view a product:

    Code:
    Source:AspDotNetStorefrontCore 
    Message:Error Calling XSLTExtension Function ProductLink: Invalid value specified for ProductID () 
    Stack Trace: 
    at AspDotNetStorefrontCore.InputValidator.ReportError(String ParamName, String ParamValue) 
    at AspDotNetStorefrontCore.InputValidator.ValidateInt(String ParamName, String ParamValue) 
    at AspDotNetStorefrontCore.XSLTExtensionBase.ProductLink(String sProductID, String sSEName, String sIncludeATag)
    and
    Code:
    Message:Error Calling XSLTExtension Function ProductLink: Invalid value specified for ProductID ()
    I am guessing the (!XmlPackage Name="facebook"!) I placed right before the </head> of my template is the cause... because it puts (!XmlPackage Name="facebook"!) on every page in text.... So, I'm guessing that is related.

    Any thoughts?
    Last edited by campbelt101; 05-27-2011 at 09:17 AM.

  2. #12
    Join Date
    Oct 2006
    Location
    South UK
    Posts
    873

    Default

    Quote Originally Posted by campbelt101 View Post
    Any comments on this... obviously I'm missing something here because I am getting the same thing. It's just printing (!XmlPackage Name="facebook"!) at the top of the page, it's not running the xml package.

    Edit: Ok, I'm running version 9.1.0.1 and I found one issue. You can't start an XML Package the old way, (!XmlPackage Name="facebook"!). I found an article that lead me to using

    Code:
    <asp:Literal ID="lit1" runat="server" Text="<%$ Tokens:Xmlpackage, facebook.xml.config %>" />
    However, this produces nothing in the source code of the page, so something still isn't working.
    Sorry - haven't looked at V9 yet - maybe someone else can chime in here?


    TTFN

    BFG

  3. #13
    Join Date
    Mar 2009
    Posts
    4

    Default Can't get it working

    Thanks, BFG!

    I followed all the directions and I can't get it to work. I am testing the code with 1 product. I just get redirected to the homepage with the following url:

    http://www.brindleysmusic.com/defaul...owproduct.aspx

    Does anyone have any ideas? I am using version 8. Here is the link to the product:
    http://www.brindleysmusic.com/p-2259...thvocoder.aspx

    Thanks in advance

  4. #14
    Join Date
    Jun 2009
    Posts
    191

    Default

    Well, this is weird... I have change the URLs to point to my site root, however, on some of the products, it still shows sitename.co.ok. Why would that be happening?

  5. #15
    Join Date
    Feb 2011
    Posts
    42

    Default

    I put
    Code:
    <%--(!XmlPackage Name="facebook.xml.config"!)--%>
    in the header and it processes fine (without writing the literal text at the top of every page like you were experiencing) but I get no output from that xml package (ie no META info in the source of the page)...

    So, it appears like the page loads but doesn't really process the facebook.xml package.

    Does anybody have any thoughts? I really want to get this to work!


    Quote Originally Posted by campbelt101 View Post
    Any comments on this... obviously I'm missing something here because I am getting the same thing. It's just printing (!XmlPackage Name="facebook"!) at the top of the page, it's not running the xml package.

    Edit: Ok, I'm running version 9.1.0.1 and I found one issue. You can't start an XML Package the old way, (!XmlPackage Name="facebook"!). I found an article that lead me to using

    Code:
    <asp:Literal ID="lit1" runat="server" Text="<%$ Tokens:Xmlpackage, facebook.xml.config %>" />
    However, this produces nothing in the source code of the page, so something still isn't working.

  6. #16
    Join Date
    Nov 2009
    Location
    UK
    Posts
    13

    Default

    Just what I was looking for. Great stuff. cheers guys. Needed the XML so that I could get a unique image to appear on each product page for the custom built share option I placed on a clients site.

    Works as treat.
    Last edited by allywidd; 07-05-2011 at 02:19 AM.
    Alun Widdowson
    -----------------------
    Premium Stores/AspdotnetStorefront Designer

    http://www.frooition.com

  7. #17
    Join Date
    Apr 2006
    Location
    Phoenix AZ
    Posts
    81

    Thumbs up

    for Multi-Store ver 9+ to call an xml package in a template or aspx page, use the following...

    Code:
    <aspdnsf:XmlPackage ID="carouselpackage" runat="server" PackageName="facebook.xml.config" />
    and make sure you register the aspdnsf tag prefix:

    Code:
    <%@ Register TagPrefix="aspdnsf" TagName="XmlPackage" Src="~/Controls/XmlPackageControl.ascx" %>

  8. #18
    Join Date
    Apr 2006
    Location
    Phoenix AZ
    Posts
    81

    Thumbs up

    here is a simplified package for MS 9+ that uses:
    • SEDescription (no need to strip html)
    • /root/System/StoreUrl and /root/System/PageName for the canonical URL (no editing and/or guessing
    • aspdnsf:ProductImageUrl to get the link to the image (no assumptions/guessing)


    Code:
    <?xml version="1.0" standalone="yes" ?>
    <package version="2.1" displayname="BFGs Facebook / rel canonical package" debug="false" includeentityhelper="false" allowengine="true">
    
      <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="555221822"/>
                <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>
    Last edited by don.irwin; 08-11-2011 at 12:27 PM.

  9. #19
    Join Date
    Apr 2009
    Posts
    19

    Thumbs up Thank you BFG

    Thanks again to BFG for sharing his knowledge and work with the community! This isn't the first time he made my site better. This fired for me on the first try...great instructions! Thanks to all the others who have shared or improved on this post too.

  10. #20
    Join Date
    Oct 2006
    Location
    South UK
    Posts
    873

    Default

    Careful - You'll make me blush!


    TTFN

    BFG

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •