/** * Changes homepage template if possible. First tries to find first landing page template in * selected templates, if none found then looks for first template restricted to contentPages, if * not found, homepage template is not changed */ protected static void adjustHomePageTemplate( final ContentPageModel homepage, final List<PageTemplateModel> pageTemplates) { // iterate over landing pages if any - take first one final PageTemplateModel landingPageTemplate = getLandingPageTemplate(pageTemplates); if (landingPageTemplate == null) { // no landing page? then iterate over ContentPages templates - take first one final PageTemplateModel contentPageTemplate = getContentPageTemplate(pageTemplates); if (contentPageTemplate != null) { homepage.setMasterTemplate(contentPageTemplate); } } else { homepage.setMasterTemplate(landingPageTemplate); } }
public static String getUrlForCMSLinkComponent( final CMSLinkComponentModel component, final Converter<ProductModel, ProductData> productUrlConverter, final Converter<CategoryModel, CategoryData> categoryUrlConverter) { // Try to get the URL from the component { final String url = component.getUrl(); if (url != null && !url.isEmpty()) { return url; } } // Try to get the label for the content page { final ContentPageModel contentPage = component.getContentPage(); if (contentPage != null) { return contentPage.getLabel(); } } // Try to get the category and build a URL to the category final CategoryModel category = component.getCategory(); if (category != null) { if (categoryUrlConverter != null) { return categoryUrlConverter.convert(category).getUrl(); } else { return getCategoryUrlConverter(getCurrentRequest()).convert(category).getUrl(); } } // Try to get the product and build a URL to the product final ProductModel product = component.getProduct(); if (product != null) { if (productUrlConverter != null) { productUrlConverter.convert(product).getUrl(); } else { return getProductUrlConverter(getCurrentRequest()).convert(product).getUrl(); } } return null; }
public static void createHomepage( final String uid, final String label, final CatalogVersionModel catVersion, final ContentCatalogModel contentCatalog, final CMSSiteModel cmsSiteModel, final List<PageTemplateModel> clonedTemplates) { final PageTemplateModel firstTemplate = clonedTemplates.iterator().next(); final ModelService modelService = UISessionUtils.getCurrentSession().getModelService(); final ContentPageModel contentPage = modelService.create(CONTENT_PAGE); contentPage.setUid(uid); contentPage.setName(uid); contentPage.setLabel(label); contentPage.setHomepage(true); contentPage.setCatalogVersion(catVersion); contentPage.setMasterTemplate(firstTemplate); contentPage.setDefaultPage(Boolean.TRUE); cmsSiteModel.setStartingPage(contentPage); adjustHomePageTemplate(contentPage, clonedTemplates); modelService.save(contentPage); }
protected void setUpMetaDataForContentPage( final Model model, final ContentPageModel contentPage) { setUpMetaData(model, contentPage.getKeywords(), contentPage.getDescription()); }