Welcome to the IBM Websphere Commerce Hub


Welcome to the IBM Websphere Commerce Hub

Come join me in my journey to explore the various features and capabilities of IBM Websphere Commerce and understand how retailers can benefit from its really cool out-of-box functionality.

Sunday, April 15, 2012

Day 1 : Introducing "wcf:url" tag


To avoid having to hard code SEO friendly URLs in the storefront pages, the WebSphere Commerce Search Engine Optimization feature provides a wcf:url tag that will construct SEO friendly URLs using the SEO pattern file(s) and tables.

The current wcf:url tag is used by all starter stores to construct SEO friendly URLs. The UrlTag class has been enhanced to support the use of the new URL pattern definition to create SEO friendly URLs.

Incase you open any JSP , for example CachedFooterDisplay.jsp, you will notice that our old friend <c:url> tag which was used to construct the URLs in WCS6 has been replaced by <wcf:url>. So, let us spend some time leaning about the tag. 


About the wcf:url tag
The wcf:url tag builds a URL and applies the appropriate WebSphere Commerce supported rewriting rules.
It contains the following additions compared to the c:url tag:
  • It builds a full path URL, rather than a relative path.
  • It builds SEO compliant URLs if the feature is used in WebSphere Commerce.
  • It adds a prefix to the URL with the appropriate protocol, HTTP or HTTPS, depending on the Struts configuration files.
To know more about the tag and its parameters , please refer Infocenter

Important Note for FEP3 and above

Both the new Feature Pack 3 and previous SEO implementations are supported. You can choose which SEO solution to use by updating wc-server.xml.


<SEOConfiguration enable="true" dynamicUrl="true" defaultUrl="www.madisons.com">
     <context-root-rewrite value="/shop"/>
     <mapper-class-name value="com.ibm.commerce.seo.url.helpers.SEOURLMapperImpl"/>
</SEOConfiguration>
 
Either value or patternName is required. If workspace is used, then both value and patternName are required. If the value parameter is provided, then URLs will be constructed based on the mapping found in SEOUrlMapper.xml file using the SEO implementation from WebSphere Commerce Version 7 to Version 7 Feature Pack 2. If patternName is provided and SEO is enabled in wc-server.xml as shown in the following example, then URLs will be constructed based on the Version 7 Feature Pack 3 SEO design, using the pattern template definitions. Preference will be given to the patternName attribute over the value attribute.

If URL construction using patternName
fails (due to an invalid patternName or a missing parameter), dynamic
URL's will be constructed if the dynamicUrl attribute is set to true.
If dynamicUrl is set to false, then wcf:url tag returns defaultUrl
specified in wc-server.xml 
The URL creation order is:
  1. If SEO Enabled and patternName specified, use patternName and construct new SEO URL
    1. If new SEO URL construction fails and dynamicUrl = true, a dynamic URL is constructed
    2. If dynamicUrl = false, a defaultUrl is constructed
  2. Otherwise the value attribute is used an old SEO URL is constructed
The following diagram helps understand the SEO URL differences and the tag parameters :

Example
The following example forms a URL to display the shopping cart using the <wcf:url> tag. It specifies the URL type as an AJAX call.
<wcf:url var="currentShoppingCartLink" value="ShopCartPageView" type="Ajax">
   <wcf:param name="storeId"   value="${WCParam.storeId}"  />
   <wcf:param name="catalogId" value="${WCParam.catalogId}"/>
   <wcf:param name="langId" value="${WCParam.langId}" />
</wcf:url>
 
Related Blogpost
Smarter SEO for Smarter Commerce

2 comments: