We used the Invocation skin token in ML8, looks like it was dropped for v9? Is that true or am I missing something. Is there an alternative?
We used the Invocation skin token in ML8, looks like it was dropped for v9? Is that true or am I missing something. Is there an alternative?
This might help: http://manual.aspdotnetstorefront.co...in-tokens.aspx
It appears that the PAGEINFO token will be your closest bet.
<%$ Tokens:PAGEINFO %> - Outputs the full page info (invocation, currency, locale, etc). This is only viewable by viewing the page source, does not display.
Will that do the trick?
In that case you could try adding adding the Literal to the master page. Then setting the value of the Literal in the masterpagebase codebehind. The value would be HttpContext.Current.Server.HtmlEncode(CommonLogic. PageInvocation())).
It's a really bad idea to use Invocation to generate a rel canonical tag - & it completely defeats the purpose of rel canonical...
As an example - all 3 of these links take you to exactly the same page, but only the first one is 'correct' :-
http://www.3mselect.co.uk/c-247-comm...-products.aspx
http://sap213.channeladvisor.com/c-2...-products.aspx
http://68.171.165.3/c-247-command-strip-products.aspx
If you take a look in the source code of any of them - you'll see the following rel canonical tag :-
C#/VB.NET Code:
<link rel="canonical" href="http://www.3mselect.co.uk/c-247-command-strip-products.aspx" />
TTFN
BFG
What exactly are you trying to achieve (the overall picture)?
I would like to generate a rel canonical tag on my category pages using this URL:
http://www.domain.com/s-1-category.aspx
This tag would also appear on URLs below so they are not indexed:
http://www.domain.com/s-1-category.aspx?pagenum=2
http://www.domain.com/s-1-category.aspx?pagenum=3
Here is how I would approach it.
1. Create XmlPackage reference in the head section of your template.
Example:
2. Create XmlPackage that will create the Canonical link tagCode:<asp:Literal ID="ltrCanonicalLink" runat="server" Text='<%$ Tokens:XMLPACKAGE, CanonicalLink.xml.config %>'></asp:Literal>
Example:
Code:<xsl:template match="/"> <link rel="canonical"> <xsl:attribute name="href"> <xsl:value-of select="concat(/root/System/StoreUrl,/root/System/PageName)"></xsl:value-of> </xsl:attribute> </link> </xsl:template>
Does that work for you?
Yes, that xml package reference works for version 9.
Use the following for 8:
(!XmlPackage Name="CanonicalLink.xml.config"!)
No, this doesn't work, either. The URL generated in the link is the actual template rather than the full query.
For example, for a category page it displays:
http://www.domain.com/showsection.aspx
Instead of:
http://www.domain.com/s-1-category.aspx
-JN
Use RequestedPage instead.
I have tested this, and it works.Code:<xsl:template match="/"> <link rel="canonical"> <xsl:attribute name="href"> <xsl:value-of select="concat(/root/System/StoreUrl,/root/System/RequestedPage)"></xsl:value-of> </xsl:attribute> </link> </xsl:template>
The complete XML Package would look like so:
Code:<?xml version="1.0" standalone="yes" ?> <package version="2.1" displayname="Entity Grid" debug="false" includeentityhelper="true"> <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="html" omit-xml-declaration="yes" /> <xsl:template match="/"> <link rel="canonical"> <xsl:attribute name="href"> <xsl:value-of select="concat(/root/System/StoreUrl,/root/System/RequestedPage)"></xsl:value-of> </xsl:attribute> </link> </xsl:template> </xsl:stylesheet> </PackageTransform> </package>
Thanks ROBB, that worked for both the 8.0.0.0 site and was able to use it on a v9 site as well!!
No problem!
BTW: In regards to the XML Package, entity helpers are not needed - you can set includeentityhelper to false.
Last edited by ROBB; 08-30-2011 at 09:21 AM.
Nice code! I have an issue. Somehow the generated canonical url is always a https
Something like:
<link rel="canonical" href="https://www.domain.com/c-106-portable-radio-en-cd-spelers.aspx">
Any ideas? I run V92
Ebijs
One of our clients is on version 9 and found all the URL's where in https as well so we changed it to this.
Simply hardcode the first section.Code:<link rel="canonical" href="http://www.mydomain.com{/root/System/FullPageName}"></link>
Or you could always do a replace like so
Either or depending on your setup.Code:<link rel="canonical"> <xsl:attribute name="href"> <xsl:value-of select="concat(aspdnsf:StrReplace(/root/System/StoreUrl,'https:','http:'),/root/System/RequestedPage)"></xsl:value-of> </xsl:attribute> </link>
Last edited by DotNetDevelopments; 10-25-2011 at 02:36 AM. Reason: Corrected code.
=====
Version (Code/DB): AspDotNetStorefront MSx 9.1.0.1/9.1.0.0
Execution Mode: 64 Bit
Dot Net Developments - E-commerce By Experience
Hi,
That was quick! Thanks.
It ran into the following error. Can you please assist?
Sijbe.
Expected token ')', found ':'.
...ot/System/StoreUrl,'https:',http -->:<-- '),/root/System/RequestedPage)
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Xml.Xsl.XslLoadException: Expected token ')', found ':'.
...ot/System/StoreUrl,'https:',http -->:<-- '),/root/System/RequestedPage)
Whoops!
Lets pretend that didn't happen I was missing a '.Code:<link rel="canonical"> <xsl:attribute name="href"> <xsl:value-of select="concat(aspdnsf:StrReplace(/root/System/StoreUrl,'https:','http:'),/root/System/RequestedPage)"></xsl:value-of> </xsl:attribute> </link>
=====
Version (Code/DB): AspDotNetStorefront MSx 9.1.0.1/9.1.0.0
Execution Mode: 64 Bit
Dot Net Developments - E-commerce By Experience
That did the trick. Thnkx!