If I want to have friendly/nice url on custom data, how do I do that in my xslt. Currently you are clicking on a category, which then lists the products, my xslt looks like this without friendly url, here's what ive done it with querystring.:
So how should my xslt look when I want to build the same with friendly urls and how do I reach the querystring after that?
Last question is how do I set the rule up in the UrlRewriting.config file for this to work. Do I have to change something on my IIS. Currently Im working local on my windows 7 machine.
Are you sure you want to make a nice url out of this? If I understand your intention correctly you want to skip the querystring paramete and then just show the product.aspx page when the visistor goes to a product page no matter the category?
I don't think that's a good idea SEO-wise - then it's better to have it rewritten like product.aspx/nameofcategorybasedontheidinquerystring.aspx if you catch my drift?
Unfortunately I'm not sure how to setup the rules in urlrewriting.net yet - but surely some others in here have and should be able to answer this :-)
if you want a friendly url on your custom data/content, you'll end up writing your own, which shouldn't be too difficult (using an xslt extension or "hard" coded in your user control). Could for example build urls based on
Combined with this setting in the config file <add key="umbracoUseDirectoryUrls" value="true" />
My productlist xslt macro:
<xsl:variable name="products" select="sql:GetDataSet('myConn', 'select p.ProductID, p.ProductName, p.CategoryID, c.CategoryName from Products p INNER JOIN Categories c ON p.CategoryID = c.CategoryID', 'Product')"/>
Friendly url on custom data in custom section
If I want to have friendly/nice url on custom data, how do I do that in my xslt. Currently you are clicking on a category, which then lists the products, my xslt looks like this without friendly url, here's what ive done it with querystring.:
<xsl:variable name="categoryID" select="umbraco.library:RequestQueryString(categoryid')"/>
<xsl:variable name="product" select="MyCustomProductLibrary:ListProductByCategory($categoryID)"></xsl:variable>
<ul>
<xsl:for-each select="$product/product">
<li>
<a>
<xsl:attribute name="href">
product.aspx?productid=<xsl:value-of select="productID"/>&
</xsl:attribute>
<xsl:value-of select="productName"/>
</a>
</li>
</xsl:for-each>
</ul>
So how should my xslt look when I want to build the same with friendly urls and how do I reach the querystring after that?
Last question is how do I set the rule up in the UrlRewriting.config file for this to work. Do I have to change something on my IIS. Currently Im working local on my windows 7 machine.
Hi testumbraco
Are you sure you want to make a nice url out of this? If I understand your intention correctly you want to skip the querystring paramete and then just show the product.aspx page when the visistor goes to a product page no matter the category?
I don't think that's a good idea SEO-wise - then it's better to have it rewritten like product.aspx/nameofcategorybasedontheidinquerystring.aspx if you catch my drift?
Unfortunately I'm not sure how to setup the rules in urlrewriting.net yet - but surely some others in here have and should be able to answer this :-)
/Jan
if you want a friendly url on your custom data/content, you'll end up writing your own, which shouldn't be too difficult (using an xslt extension or "hard" coded in your user control). Could for example build urls based on
http://www.domain.com/products/category-name(.aspx) and http://www.domain.com/products/category-name/product-name(.aspx)
From there on, use urlRewriting to rewrite to
http://www.domain.com/products/category.aspx?name=category-name and http://www.domain.com/product.aspx?name=product-name
in urlRewriting.config
(written without have tested...)
Also assumes you've setup a /category.aspx and /product.aspx page in your content tree (with associated templates)
But, one thing to be aware of.. make sure to have unique categories and product names....
Let us know if you need more info...
Cheers,
/Dirk
Thanks for the replies.
I did following steps:
Ive created products, product and category pages under content.
From this tuturial I configure my IIS (Wildcard script mapping in IIS 7 classic pipeline mode), this ensures the flat url without .aspx
http://learn.iis.net/page.aspx/508/wildcard-script-mapping-and-iis-7-integrated-pipeline/
Combined with this setting in the config file
<add key="umbracoUseDirectoryUrls" value="true" />
My productlist xslt macro:
<xsl:variable
name="products"
select="sql:GetDataSet('myConn', 'select p.ProductID, p.ProductName, p.CategoryID, c.CategoryName from Products p INNER JOIN Categories c ON p.CategoryID = c.CategoryID', 'Product')"/>
<xsl:template match="/">
<ul>
<xsl:for-each select="$products//Product">
<xsl:sort select="ProductName"/>
<li>
<a>
<xsl:attribute name="href">
products/<xsl:value-of select="CategoryName "/>/<xsl:value-of select="ProductName"/>
</xsl:attribute>
<strong>
<xsl:value-of select="ProductName"/>
</strong>
</a>
</li>
</xsl:for-each>
</ul>
</xsl:template>
Here Ive have my xslt extensions which grabs my products from a database. The highlighted text is my friendly url.
Then I added a urlrewrite rule to my config
<add name="produktidrewrite"
virtualUrl="^/products/(.*)/(.*)"
rewriteUrlParameter="ExcludeFromClientQueryString"
destinationUrl="~/product.aspx?productid=$2&category=$1"
ignoreCase="true"/>
My final url looks like
http://mydomain/products/Seafood/Carnarvon-Tigers (where seafood is the category and carnarvon-tiger is the product)
Seems ok, just be aware of special chars in your urls, such as é, à, &, ...., they may corrupt the url...
Cheers,
/Dirk
is working on a reply...