Display Related Content Listed by Categories in a Multilingual Environment

Description

Sometimes you want to display related content listed and classified by category in a multilingual environment.

Code

${esc.hash}${esc.hash}${esc.hash}Use this line if you want the categories to be displayed alphabetically by their name${esc.hash}${esc.hash}${esc.hash}
${esc.hash}${esc.hash}foreach(${esc.dollar}cat in ${esc.dollar}sorter.sort(${esc.dollar}categories. getChildrenCategoriesByKey("EnterCategoryKey"), "categoryName"))

${esc.hash}foreach(${esc.dollar}cat in ${esc.dollar}categories. getChildrenCategoriesByKey("EnterCategoryKey"))
${esc.hash}${esc.hash}This flag makes sure that the category name is displayed only once.
${esc.hash}set(${esc.dollar}flag1 = 'true')
${esc.hash}foreach(${esc.dollar}con in  ${esc.dollar}dotcontent.pullRelated(" RelationshipName","${esc.dollar}!{URLMapContent.identifier}","+(categories:${esc.dollar}cat.categoryVelocityVarName)",false,0,"StructureName.day"))     

${esc.hash}if(${esc.dollar}flag1 == 'true')
   <p>

${esc.hash}${esc.hash}In a multilingual environment it is best to use the category key to create a language key variable and handle the translation that way.

<strong>${esc.dollar}text.get("content.restaurants.${esc.dollar}cat.key")</strong></p>
${esc.hash}set(${esc.dollar}flag1 = 'false')
${esc.hash}end