Class ContentProcessor
java.lang.Object
org.broadleafcommerce.presentation.dialect.AbstractBroadleafVariableModifierProcessor
org.broadleafcommerce.cms.web.processor.ContentProcessor
- All Implemented Interfaces:
org.broadleafcommerce.presentation.dialect.BroadleafProcessor,org.broadleafcommerce.presentation.dialect.BroadleafVariableModifierProcessor
@Component("blContentProcessor")
@ConditionalOnTemplating
public class ContentProcessor
extends org.broadleafcommerce.presentation.dialect.AbstractBroadleafVariableModifierProcessor
Processor used to display structured content that is maintained with the Broadleaf CMS.
Usage based on the following attributes:
- contentType (required *) - only required if an extension manager is not defined to handle content lookup. If the content type is not found, it will try to retrieve content from any registered extension handlers. Specifies the content you are retrieving.
- contentName - if included will retrieve only content that matches the name. When no name is specified, all matching content items of the passed in type are retrieved.
- maxResults - if specified limits the results to a specified number of items. The content will be returned according to priority. If content items share the same priority, then they will be returned randomly. Consider the example with 5 matching items with priorities (1,2,3,3,3) respectively. If the count is set to 3. Items 1 and 2 will ALWAYS be returned. The third item returned will randomy rotate through the 3rd, 4th, and 5th item.
- contentListVar - allows you to specify an alternate name for the list of content results. By default, the results are returned in the page attributed "contentList"
- contentItemVar - since a typical usage is to only return one item, the first item is returned in the variable "contentItem". This variable can be used to change the attribute name.
- numResultsVar - variable holding the returns the number of results being returned to through the tag-lib. defaults to "numResults".
- fieldFilters - Thymeleaf key-value pair to filter the resulting StructuredContentDTO by particular field values. For instance, if you had a field in a piece of structured content called 'featured' and you wanted to return all of the featured content items, you could do the following: <blc:content fieldFilters="featured=${'true'},otherField=${'someValue'}" />
- sorts - sorts to apply to the resulting list of content. These should be key-value pairs corresponding where the key is the field to sort and the value is the direction of the sort. If unspecified, the default sorting is used (by priority). The sort fields must occur in the dynamic fields for that piece of structured content. For instance: <blc:content sort="dynamicFieldA='DESCENDING',dynamicFieldB='ASCENDING'" /> The list will be sorted first by dynamicFieldA descending and then dynamicFieldB ascending
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringprotected ContentDeepLinkServiceImplprotected ContentProcessorExtensionManagerprotected final org.apache.commons.logging.Logstatic final Stringprotected StaticAssetServiceprotected StructuredContentServiceFields inherited from interface org.broadleafcommerce.presentation.dialect.BroadleafProcessor
DEFAULT_PRECEDENCE, DEFAULT_PREFIX -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuildMvelParameters(jakarta.servlet.http.HttpServletRequest request, Map<String, String> tagAttributes, org.broadleafcommerce.presentation.model.BroadleafTemplateContext context) MVEL is used to process the content targeting rules.protected StringReturns a default nameprotected List<org.broadleafcommerce.common.structure.dto.StructuredContentDTO>getContentItems(String contentName, Integer maxResults, jakarta.servlet.http.HttpServletRequest request, Map<String, Object> mvelParameters, org.broadleafcommerce.common.sandbox.domain.SandBox currentSandbox, StructuredContentType structuredContentType, org.broadleafcommerce.common.locale.domain.Locale locale, String tagName, Map<String, String> tagAttributes, Map<String, Object> newModelVars, org.broadleafcommerce.presentation.model.BroadleafTemplateContext context) getName()intbooleanisSecure(jakarta.servlet.http.HttpServletRequest request) populateModelVariables(String tagName, Map<String, String> tagAttributes, org.broadleafcommerce.presentation.model.BroadleafTemplateContext context) Methods inherited from class org.broadleafcommerce.presentation.dialect.AbstractBroadleafVariableModifierProcessor
getCollectionModelVariableNamesToAddTo, getPrefix, useGlobalScope
-
Field Details
-
LOG
protected final org.apache.commons.logging.Log LOG -
REQUEST_DTO
- See Also:
-
BLC_RULE_MAP_PARAM
- See Also:
-
structuredContentService
-
staticAssetService
-
extensionManager
-
contentDeepLinkService
-
-
Constructor Details
-
ContentProcessor
public ContentProcessor()
-
-
Method Details
-
getName
-
getPrecedence
public int getPrecedence()- Specified by:
getPrecedencein interfaceorg.broadleafcommerce.presentation.dialect.BroadleafProcessor- Overrides:
getPrecedencein classorg.broadleafcommerce.presentation.dialect.AbstractBroadleafVariableModifierProcessor
-
getAttributeValue
protected String getAttributeValue(Map<String, String> tagAttributes, String valueName, String defaultValue) Returns a default name- Parameters:
element-valueName-- Returns:
-
populateModelVariables
-
getContentItems
protected List<org.broadleafcommerce.common.structure.dto.StructuredContentDTO> getContentItems(String contentName, Integer maxResults, jakarta.servlet.http.HttpServletRequest request, Map<String, Object> mvelParameters, org.broadleafcommerce.common.sandbox.domain.SandBox currentSandbox, StructuredContentType structuredContentType, org.broadleafcommerce.common.locale.domain.Locale locale, String tagName, Map<String, String> tagAttributes, Map<String, Object> newModelVars, org.broadleafcommerce.presentation.model.BroadleafTemplateContext context) - Parameters:
contentName- name of the content to be looked up (can be null)maxResults- maximum results to returnrequest- servlet requestmvelParameters- values that should be considered when filtering the content list by rulesstructuredContentType- the type of content that should be returnedlocale- current localearguments- Thymeleaf Arguments passed into the tagelement- element context that this Thymeleaf processor is being executed in- Returns:
-
buildMvelParameters
protected Map<String,Object> buildMvelParameters(jakarta.servlet.http.HttpServletRequest request, Map<String, String> tagAttributes, org.broadleafcommerce.presentation.model.BroadleafTemplateContext context) MVEL is used to process the content targeting rules.- Parameters:
request-- Returns:
-
isSecure
public boolean isSecure(jakarta.servlet.http.HttpServletRequest request)
-