Modifying dynamic Recipe URLs to contain desired input fields for constructing SEO friendly URLs
The current Recipe URL
page contains some parameters in its dynamic URL that is not compatible
with constructing SEO friendly URLs. In this section you will modify
the recipe page so that the current recipe implementation is maintained
when constructing SEO friendly URLs.
Procedure
- Navigate to Stores > WebContent > WEB-INF > config > com.mycompany.commerce.project
- Edit get-data-config.xml to define
a new expression builder to retrieve ProjectCollection objects by
their unique collectionId.
- Add the following code under the wcf:get-data-config object
tag:
<!-- Get Collections by their UniqueID --> <expression-builder> <name>getCollectionsByID</name> <data-type-name>ProjectCollection</data-type-name> <expression-template>{_wcf.ap=$accessProfile$}/ProjectCollection[ProjectCollectionIdentifier[(UniqueID='$collectionID$')]]</expression-template> <param> <name>accessProfile</name> <value>MyCompany_Store_Details</value> </param> </expression-builder>
- Save and close the file.
- Add the following code under the wcf:get-data-config object
tag:
- Navigate to Stores > WebContent > storedir > ShoppingArea > RecipeSection.
- Modify the RecipeCollection.jsp page to pass a collection
parameter into the Recipe URL and to remove the collectionName parameter
from the page title and replace it by retrieving the information from
a service request.
- Locate the following code:
Add the following code below it:<wcf:getData type="com.mycompany.commerce.project.facade.datatypes.ProjectType[]" var="projects" expressionBuilder="getProjectsByCollection" maxItems="5" recordSetReferenceId="$ {param.recordSetReferenceId}" recordSetStartNumber="${param.recordSetStartNumber}" varShowVerb="showVerb"> <wcf:contextData name="storeId" data="${WCParam.storeId}"/> <wcf:param name="collectionID" value="${param.collection}"/> </wcf:getData>
<wcf:getData type="com.mycompany.commerce.project.facade.datatypes.ProjectCollectionType" var="collection" expressionBuilder="getCollectionsByID" varShowVerb="showVerb"> <wcf:param name="collectionID" value="${param.collection}"/> </wcf:getData>
- Locate the following line of code:
replace it with the following:<title>${param.collectionName}</title>
<title>${collection.projectCollectionIdentifier.externalIdentifier.name}</title>
- Locate the following line of code:
replace it with the following:<div id="RecipeCollectiontitle" class="Recipe_label_2">${param.collectionName}</div>
<div id="RecipeCollectiontitle" class="Recipe_label_2">${collection.projectCollectionIdentifier.externalIdentifier.name}</div>
- Locate the following URL construct code::
add the collection parameter which we will make use of later in the tutorial to construct the new URLs:<wcf:url var="RecipeDisplayURL" value="RecipeDisplay1" > <wcf:param name="project" value="${project.projectIdentifier.uniqueID}" /> <wcf:param name="langId" value="${langId}" /> <wcf:param name="storeId" value="${WCParam.storeId}" /> <wcf:param name="catalogId" value="${WCParam.catalogId}" /> </wcf:url>
<wcf:url var="RecipeDisplayURL" value="RecipeDisplay" > <wcf:param name="project" value="${project.projectIdentifier.uniqueID}" /> <wcf:param name="langId" value="${langId}" /> <wcf:param name="storeId" value="${WCParam.storeId}" /> <wcf:param name="catalogId" value="${WCParam.catalogId}" /> <wcf:param name="collection" value="${collection.projectCollectionIdentifier.uniqueID}" /> </wcf:url>
- Locate the following code:
- Open RecipeSection.jsp. Locate and
remove the following line:
<wcf:param name="collectionName" value="${collection.projectCollectionIdentifier.externalIdentifier.name}" />