أنت تعرض محتوى المساعدة للإصدار:

Editable templates have been introduced to:

  • Allow (specialized) authors to create and edit templates.
    • These authors must be members of the template-authors group.
  • Provide templates that retain a dynamic connection to any pages created from them; this ensures that any changes to the template are reflected in the pages themselves.
  • Make the page component more generic so the foundation page component can be used without customization.

ملاحظة:

Static templates are also available.

Creating a new Template

When creating a new editable template you:

  1. Create a folder for the templates (recommended).

    تحذير:

    Folders must be created by a user with admin rights.

  2. Select a template type; this is copied to create the template definition.

    ملاحظة:

    A selection of template types are provided out-of-the-box. You can also create your own site-specific template types if required.

  3. Configure the structure, content policies, initial content, layouting, page design and page policies of the new template.

ملاحظة:

Authors can create and configure editable templates with the touch-optimized UI using the template console and template editor.

ملاحظة:

The editor client library assumes the presence of the cq.shared namespace in content pages, and if it is absent the JavaScript error Uncaught TypeError: Cannot read property 'shared' of undefined will result.

All sample content pages contain cq.shared, so any content based on them automatically includes cq.shared. However, if you decide to create your own content pages from scratch without basing them on sample content, you must make sure to include the cq.shared namespace.

See Using Client-Side Libraries for further information.

Template Folders

For organizing your templates you can use the following folders:

  • global
  • Site-specific
    The site-specific folders that you create to organize your templates are created with an account holding admin priviliges. See Creating a Template Folder - Admin for the steps and details.

ملاحظة:

Even though you can nest your folders, when the user views them in the Templates console they are presented as a flat structure.

ACLs and Groups

To ensure security, both types of folder requires ACLs defined for the appropriate groups:

Path Role / Group Permissions - Author Environment
Permissions - Publish Environment
Description
/conf/global/settings/wcm/templates template-authors read, write, replicate read, write, replicate In a standard installation the template-authors group is empty.
/conf/global/settings/wcm/policies everyone read read  
/conf/<your-folder>/settings/wcm/templates template-authors
read, write, replicate read, write, replicate In a standard installation the template-authors group is empty.
/conf/<your-folder>/settings/wcm/policies everyone read read  

Template Type

When creating a new template you need to specify a template type:

  • Template types effectively provide templates for a template; when creating a new template the structure and initial content of the selected template type is used to create to the new template.
    • The template type is copied to create the template.
    • Once the copy has occurred, the only connection between the template and the template type is a static reference for information purposes.
  • Template types allow you to define:
    • The resource type of the page component.
    • The policy of the root node, which defines the components allowed in the template editor.
    • Optionally (but recommended), the breakpoints for the responsive grid and setup of the mobile emulator. This is optional, because the configuration could also be defined on the root page of the site.
  • AEM provides a small selection of out-of-the-box template types; for example HTML5 Page, Adaptive Form page.
  • Template types are defined by developers and cannot be edited through the UI.

The out-of-the box template types are stored under:

  • /libs/settings/wcm/template-types

Your site-specific template types should be stored in the comparable location of:

  • /apps/settings/wcm/template-types

تحذير:

You must not change anything in the /libs path.

This is because the content of /libs is overwritten the next time you upgrade your instance (and may well be overwritten when you apply either a hotfix or feature pack).

Definitions for your customized templates types should be stored in folders, either global or user defined; for example:

  • /conf/global/settings/wcm/template-types
  • /conf/<my-folder>/settings/wcm/template-types
  • /conf/<my-folder-01>/<my-folder-02>/settings/wcm/template-types

تحذير:

The template types have to respect the correct folder structure (i.e. /settings/wcm/...), otherwise the template types will not be found.

Template Definitions

Definitions for editable templates are stored in folders, either global or user defined; for example:

  • /conf/global/settings/wcm/templates
  • /conf/<my-folder>/settings/wcm/templates
  • /conf/<my-folder-01>/<my-folder-02>/settings/wcm/templates

The root node of the template is of type cq:Template with a skeleton structure of:

<template-name>
  initial
    jcr:content
      root
        <component>
        ...
        <component>
  jcr:content
    @property status
  policies
    jcr:content
      root
        @property cq:policy
        <component>
          @property cq:policy
        ...
        <component>
          @property cq:policy
  structure
    jcr:content
      root
        <component>
        ...
        <component>
      cq:responsive
        breakpoints
  thumbnail.png

The main elements are:

jcr:content

This node holds properties for the template:

  • Name: jcr:title
  • Name: status
    • Type: String
    • Value: draft, enabled or disabled

Structure

Defines the structure of the resultant page:

  • Is merged with the initial content (/initial) when creating a new page.
  • Changes made to the structure will be reflected in any pages created with the template.
  • The root (structure/jcr:content/root) node defines the list of components that will be available in the resulting page.
    • Components defined in the template structure cannot be moved/deleted from any resultant pages.
    • Once a component is unlocked the editable property is set to true.
    • Once a component that already contains content is unlocked, this content will be moved to the initial branch
  • The cq:responsive node holds definitions for the responsive layouting.

Initial Content

Defines the initial content that a new page will have upon creation:

  • Contains a jcr:content node that is copied to any new pages.
  • Is merged with the structure (/structure) when creating a new page.
  • Any existing pages will not be updated if the initial content is changed after creation.
  • The root node holds a list of components to define what will be available in the resulting page.
  • If content is/has been added to a component in structure mode and that component is subsequently unlocked (or vice versa), then this content is used as initial content.

Layouting

Content Policies

The content (or design) policies define the design properties of a component; for example, the components available, minimal and/or maximal dimensions. These are applicable to the template (and pages created with the template). Content policies can be created and selected in the template editor of the touch-optimized UI.

  • The property cq:policy, on the root node
    /conf/<your-folder>/settings/wcm/templates/<your-template>/policies/jcr:content/root
    Provides a relative reference to the content policy for the page's paragraph system.
  • The property cq:policy, on the component-explicit nodes under root, provide links to the policies for the individual components.
  • The actual policy definitions are stored under:
    /conf/<your-folder>/settings/wcm/policies/wcm/foundation/components

ملاحظة:

The paths of policy definitions depend on the path of the component; cq:policy holds a relative reference to the configuration itself.

ملاحظة:

Pages created from editable templates do not offer a Design mode in the page editor.

The policies tree of an editable template has the same hierarchy as the design mode configuration of a static template under:

    /etc/designs/<my-site>/jcr:content/<component-name>

The design mode configuration of a static template was defined per page component.

Page Policies

Page policies allow you to define the content policy for the page (main parsys), in either the template or resultant pages.

Enabling and Allowing a Template for Use

  1. Enable the Template

    Before a template can be used it must be enabled by either:

    1. Enabling the template from the Templates console.
    2. Setting the status property on the jcr:content node.
      • For example, on:
        /conf/<your-folder>/settings/wcm/templates/<your-template>/jcr:content
      • Define the property:
        • Name: status
        • Type: String
        • Value: enabled
  2. Allowed Templates

    For example, with a value of:

    /conf/<your-folder>/settings/wcm/templates/.*

Resultant Content Pages

Pages created from editable templates:

  • Are created with a subtree that is merged from structure and initial in the template
  • Have references to information held in the template and template type; this is achieved with a jcr:content node with the properties:
    • cq:template
      Provides the dynamic reference to the actual template; enables changes to the template to be reflected on the actual pages.
    • cq:templateType
      Provides a reference to the template type.
chlImage_1

The above diagram shows how templates, content and components interrelate:

  • Controller - /content/<my-site>/<my-page>
    The resultant page that references the template. The content controls the entire process. According to the definitions it accesses the appropriate template and components.
  • Configuration - /conf/<my-folder>/settings/wcm/templates/<my-template>
    The template, and related content policies, define the page configuration.
  • Model - OSGi bundles
    The OSGI bundles implement the functionality.
  • View - /apps/<my-site>/components
    One both the author and publish environments the content is rendered by components.

When rendering a page:

  • Templates:

    • The cq:template property of its jcr:content node will be referenced to access the template that corresponds to that page.
  • Components:

    • The page component will merge the structure/jcr:content tree of the template with the jcr:content tree of the page.
    • The page component will only allow the author to edit the nodes of the template structure that have been flagged as editable (as well as any children).
    • When rendering a component on a page, the relative path of that component will be taken from the jcr:content node; the same path under the policies/jcr:content node of the template will then be searched.
      • The cq:policy property of this node points to the actual content policy (i.e. it holds the design configuration for that component).
      • This allows you to have multiple templates that re-use the same content policy configurations.

تم ترخيص هذا العمل بموجب الترخيص العام غير المعدل الخاص بالإسناد وعدم التجارة والمشاركة الإصدار 3.0 ‏من ‏‏Creative Commons‏‏  إن بنود Creative Commons لا تشمل منشورات Twitter™‎ وFacebook.

إشعارات قانونية   |   سياسة الخصوصية على الإنترنت