Interface I_CmsTemplateContextProvider

  • All Known Implementing Classes:

    public interface I_CmsTemplateContextProvider
    Interface for template context providers.

    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.

    • Method Detail

      • getAllContexts

        Gets a map of all template contexts, with the template context names as keys.

        the map of template context providers
      • getEditorStyleSheet

        java.lang.String getEditorStyleSheet​(CmsObject cms,
                                             java.lang.String editedResourcePath)
        Returns the style sheet to be used for the editor.

        cms - the current CMS context
        editedResourcePath - the path of the edited resource
        the path of the style sheet to be used for the resource
      • getOverrideCookieName

        java.lang.String getOverrideCookieName()
        Gets the name of the cookie which should be used for overriding the template context.

        the name of the cookie used for overriding the template context
      • getTemplateContext

        CmsTemplateContext getTemplateContext​(CmsObject cms,
                                              javax.servlet.http.HttpServletRequest request,
                                              CmsResource resource)
        Determines the template context from the current CMS context, request, and resource.

        cms - the CMS context
        request - the current request
        resource - the resource being rendered
        the current template context
      • initialize

        void initialize​(CmsObject cms,
                        java.lang.String config)
        Initializes the context provider using a CMS object.

        cms - the current CMS context
        config - the template context provider configuration
      • readCommonProperty

        java.lang.String readCommonProperty​(CmsObject cms,
                                            java.lang.String propertyName,
                                            java.lang.String fallbackValue)
                                     throws CmsException
        Gets the value which should be used instead of a property which was read from the template resource.

        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 use
        propertyName - the name of the property
        fallbackValue - the value to return if no value is found or an error occurs
        the common property value
        CmsException - if something goes wrong