[{"data":1,"prerenderedAt":108},["ShallowReactive",2],{"article-\u002Fblog\u002Fsap-commerce-frontend-template-addon":3},{"id":4,"title":5,"author":6,"body":7,"description":94,"extension":95,"intro":96,"meta":97,"name":96,"navigation":99,"path":100,"pubDate":101,"role":96,"seo":102,"stem":103,"tags":104,"__hash__":107},"content\u002Fblog\u002Fsap-commerce-frontend-template-addon.md","Loading a JSP for a Page Template From an Addon","Danny Krämer",{"type":8,"value":9,"toc":92},"minimark",[10,19,42,49,67,88],[11,12,13,14,18],"p",{},"If you use an Accelerator Storefront in your SAP Commerce project, you might want to introduce a new page template for a CMS site. A page template needs an associated JSP that is used to render the page. You add the path to the JSP in the field ",[15,16,17],"code",{},"frontendTemplateName",". So, we could write an Impex like this:",[20,21,26],"pre",{"className":22,"code":23,"language":24,"meta":25,"style":25},"language-Impex shiki shiki-themes github-dark github-light","INSERT_UPDATE PageTemplate; $contentCV[unique = true]; uid[unique = true]; name; frontendTemplateName; restrictedPageTypes(code); active[default = true];  \n                          ;                          ; \u003CYourPageTemplate>; \u003CYourPageTemplateName>; \u002Fpages\u002Flayout\u002F\u003Cyour-template>; ContentPage;\n","Impex","",[15,27,28,36],{"__ignoreMap":25},[29,30,33],"span",{"class":31,"line":32},"line",1,[29,34,35],{},"INSERT_UPDATE PageTemplate; $contentCV[unique = true]; uid[unique = true]; name; frontendTemplateName; restrictedPageTypes(code); active[default = true];  \n",[29,37,39],{"class":31,"line":38},2,[29,40,41],{},"                          ;                          ; \u003CYourPageTemplate>; \u003CYourPageTemplateName>; \u002Fpages\u002Flayout\u002F\u003Cyour-template>; ContentPage;\n",[11,43,44,45,48],{},"If we do it like this, the template is loaded from your storefront extension in the following directory: ",[15,46,47],{},"\u003Cyourstorefrontextension>\u002Fweb\u002Fwebroot\u002FWEB-INF\u002Fviews\u002Fresponsive\u002Fpages\u002Flayout",".",[11,50,51,52,59,60,63,64,48],{},"Now, I created a",[53,54,58],"a",{"href":55,"rel":56},"https:\u002F\u002Fhelp.sap.com\u002Fdocs\u002FSAP_COMMERCE\u002Fb490bb4e85bc42a7aa09d513d0bcb18e\u002F8adf7365866910149ceb975f778d809d.html",[57],"nofollow"," storefront addon extension to modify an existing storefront",". JSPs from an addon get copied into the storefront in the ",[15,61,62],{},"views\u002Faddons\u002F\u003Cyouraddon>\u002Fresponsive\u002F",". So, how do we tell the system to look into that directory? It does not work to just write something like ",[15,65,66],{},"..\u002Faddons\u002F\u003Cyouraddon>\u002Fresponsive\u002Fpages\u002Flayout",[11,68,69,70,72,73,76,77,80,81,83,84,87],{},"It took me some time and extensive Google searches to find the solution: The string in the ",[15,71,17],{}," gets special parsing treatment. The storefront has a ",[15,74,75],{},"UiExperienceViewResolver",", and there the path to the template gets parsed. As it turns out, if you put ",[15,78,79],{},"addon:"," before your path, SAP Commerce searches in the addon directory instead of the base storefront template directory. So, if we change the string for the ",[15,82,17],{}," in the Impex to ",[15,85,86],{},"addon:\u002F\u003Cyouraddon>\u002Fpages\u002Flayout\u002F\u003Cyour-template>",", it works just fine.",[89,90,91],"style",{},"html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"title":25,"searchDepth":38,"depth":38,"links":93},[],"A custom page template in an SAP Commerce Accelerator Storefront addon can be properly referenced by using the prefix \"addon:\" in the frontendTemplateName field of the PageTemplate Impex.","md",null,{"image":98},{"url":25,"alt":25},true,"\u002Fblog\u002Fsap-commerce-frontend-template-addon","2024-10-11",{"title":5,"description":94},"blog\u002Fsap-commerce-frontend-template-addon",[105,106],"sap-commerce","smartedit","65h-j5YB-tmFenHWUjwcBkdWtAVvabLgtZgpRSPxjG0",1775933922347]