Introduced in Feature Pack 3

Modifying dynamic Recipe URLs to contain desired input fields for constructing SEO friendly URLs

Introduced in Feature Pack 3 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

  1. Navigate to Stores > WebContent > WEB-INF > config > com.mycompany.commerce.project
  2. Edit get-data-config.xml to define a new expression builder to retrieve ProjectCollection objects by their unique collectionId.
    1. 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>
    2. Save and close the file.
  3. Navigate to Stores > WebContent > storedir > ShoppingArea > RecipeSection.
  4. 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.
    1. Locate the following code:
      <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>
      Add the following code below it:
      <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>
    2. Locate the following line of code:
       <title>${param.collectionName}</title>
      replace it with the following:
      <title>${collection.projectCollectionIdentifier.externalIdentifier.name}</title>
    3. Locate the following line of code:
      <div id="RecipeCollectiontitle" class="Recipe_label_2">${param.collectionName}</div> 
      replace it with the following:
      <div id="RecipeCollectiontitle" class="Recipe_label_2">${collection.projectCollectionIdentifier.externalIdentifier.name}</div>
    4. Locate the following URL construct code::
      <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> 
      add the collection parameter which we will make use of later in the tutorial to construct the new URLs:
      <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>
  5. Open RecipeSection.jsp. Locate and remove the following line:
    <wcf:param name="collectionName" value="${collection.projectCollectionIdentifier.externalIdentifier.name}" />