public interface I_CmsTemplateContextProvider
Implementations of this class are used to dynamically determine a template used for rendering a page at runtime, e.g. there could be one template for desktop browsers and another for mobile browsers. It is possible to override the template using a cookie containing the name of the template context which should be used as a value. The cookie name is determined by the template context provider.
限定符和类型 | 方法和说明 |
---|---|
java.util.Map<java.lang.String,CmsTemplateContext> |
getAllContexts()
Gets a map of all template contexts, with the template context names as keys.
|
java.lang.String |
getEditorStyleSheet(CmsObject cms,
java.lang.String editedResourcePath)
Returns the style sheet to be used for the editor.
|
java.lang.String |
getOverrideCookieName()
Gets the name of the cookie which should be used for overriding the template context.
|
CmsTemplateContext |
getTemplateContext(CmsObject cms,
javax.servlet.http.HttpServletRequest request,
CmsResource resource)
Determines the template context from the current CMS context, request, and resource.
|
void |
initialize(CmsObject cms,
java.lang.String config)
Initializes the context provider using a CMS object.
|
java.lang.String |
readCommonProperty(CmsObject cms,
java.lang.String propertyName,
java.lang.String fallbackValue)
Gets the value which should be used instead of a property which was read from the template resource.
|
java.util.Map<java.lang.String,CmsTemplateContext> getAllContexts()
java.lang.String getEditorStyleSheet(CmsObject cms, java.lang.String editedResourcePath)
cms
- the current CMS contexteditedResourcePath
- the path of the edited resourcejava.lang.String getOverrideCookieName()
CmsTemplateContext getTemplateContext(CmsObject cms, javax.servlet.http.HttpServletRequest request, CmsResource resource)
cms
- the CMS contextrequest
- the current requestresource
- the resource being renderedvoid initialize(CmsObject cms, java.lang.String config)
cms
- the current CMS contextconfig
- the template context provider configurationjava.lang.String readCommonProperty(CmsObject cms, java.lang.String propertyName, java.lang.String fallbackValue) throws CmsException
This is needed because before template context providers, it was common to store template-specific configuration in a property on the template JSP. Since template context providers make the result ambiguous, this method is intended as a replacement.
cms
- the CMS context to usepropertyName
- the name of the propertyfallbackValue
- the value to return if no value is found or an error occursCmsException
- if something goes wrong