diff --git a/src/helpers/cms-content-helper.js b/src/helpers/cms-content-helper.js index d6c89b2e..6805908b 100644 --- a/src/helpers/cms-content-helper.js +++ b/src/helpers/cms-content-helper.js @@ -4,22 +4,31 @@ import { useMainStore } from '@/store'; export function fetchCmsContentForPage(issPage) { const store = useMainStore() const clientName = "ClientOverrideTest";//store.issConfig.clientName; - const pageName = issPage + (clientName.length == 0 ? "" : "_" + clientName); + const clientOverride = (clientName.length == 0); + const pageName = issPage + (clientOverride ? "" : "_" + clientName.toLowerCase().replace(/ /g, "")); return store.getPageData(issPage) .then( // Get the base/default page first. - (baseResponse) => { - return store.getPageData(pageName) - .then( - // Get the client override if it exists. - (clientResponse) => { - return processPageData(baseResponse, clientResponse); - }, - (error) => { - return processPageData(baseResponse, null); - } - ); + (baseResponse) => { + if ( !clientOverride ){ + // Return the base page if there are no client override. + return processPageData(baseResponse, null); + } + else { + // Else get the client override page. + return store.getPageData(pageName) + .then( + (clientResponse) => { + // Process the client override if it exists. + return processPageData(baseResponse, clientResponse); + }, + (error) => { + // Process the just the base if no client override exists. + return processPageData(baseResponse, null); + } + ); + } } ); };