|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Manages the association between publishable content items and templates in a content section.
Many sites offer alternative views of the same content item depending on device or browser, or on user preference. For example, a site may have "plain" and "fancy" versions of its pages. The fancy versions would be the defaults, while the plain versions would be appropriate for users with low-bandwidth connections, older browsers, or a distaste for flashy appurtenances. In this the case the selection might be made based on a cookie.
Another common example is the "printable" version of a page. In this case a query variable might be more appropriate.
In general, the process for resolving a template involves two steps:
Field Summary | |
static String |
PUBLIC_CONTEXT
The default use context for templates |
static String |
versionId
|
Method Summary | |
void |
addTemplate(ContentItem item,
Template template,
String context)
Assign a template to the item in the given context. |
void |
addTemplate(ContentSection section,
ContentType type,
Template template,
String context)
Add a template to the given content type for the given content section. |
void |
addTemplate(ContentSection section,
ContentType type,
Template template,
String context,
boolean isDefault)
Add a template to the given content type for the given content section. |
com.arsdigita.cms.ItemTemplateCollection |
getContextsWithTypes(ContentItem item)
Retrieve all use context/mime type combinations along with possibly null template for the item in that pair. |
Template |
getDefaultTemplate(ContentSection section,
ContentType type,
String context)
Deprecated. Use getDefaultTemplate(ContentSection, ContentType, String, MimeType) |
Template |
getDefaultTemplate(ContentSection section,
ContentType type,
String context,
com.arsdigita.mimetypes.MimeType mimeType)
Get the default template for the given section, type and use context |
Template |
getTemplate(ContentItem item,
String context)
Retrieve a template for the item in the given use context. |
TemplateCollection |
getTemplates(ContentItem item)
Retrieve all templates for the content item, along with their use contexts |
TemplateCollection |
getTemplates(ContentSection section,
ContentType type)
Get all the templates within the given section and type |
TemplateCollection |
getTemplates(ContentSection section,
ContentType type,
String context)
Get all the templates within the given section, type and context |
TemplateCollection |
getUseContexts(ContentItem item)
Retrieve a collection of all use contexts for the item, along with the templates assigned to each use context (if any). |
void |
removeTemplate(ContentItem item,
Template template,
String context)
Unassign a template from the item in the given context. |
void |
removeTemplate(ContentSection section,
ContentType type,
Template template,
String context)
Remove the specified template from the content type in the given context. |
void |
setDefaultTemplate(ContentSection section,
ContentType type,
Template template,
String context)
Designate the given template as the default template within its use context. |
Field Detail |
public static final String versionId
public static final String PUBLIC_CONTEXT
Method Detail |
public void addTemplate(ContentItem item, Template template, String context)
item
- the content itemtemplate
- the template to be assignedcontext
- the use context for the template, such as "public" or
"abridged".public void removeTemplate(ContentItem item, Template template, String context)
item
- the content itemtemplate
- the template to be unassignedcontext
- the use context for the template, such as "public" or
"abridged".public void addTemplate(ContentSection section, ContentType type, Template template, String context)
section
- the content section to which the template will belongtype
- the content type to which the template will belongtemplate
- the template to be addedcontext
- the use context for the template, such as "public" or
"abridged".public void removeTemplate(ContentSection section, ContentType type, Template template, String context)
section
- the content section to which the template belongstype
- the content type to which the template belongstemplate
- the template to be removedcontext
- the use context for the template, such as "public" or
"abridged".public void addTemplate(ContentSection section, ContentType type, Template template, String context, boolean isDefault)
section
- the content section to which the template will belongtype
- the content type to which the template will belongtemplate
- the template to be addedcontext
- the use context for the template, such as "public" or
"abridged".isDefault
- if true, new content items of the given type will
use this template by default when they are rendered within the specified
use contextpublic void setDefaultTemplate(ContentSection section, ContentType type, Template template, String context)
addTemplate(com.arsdigita.cms.ContentItem, com.arsdigita.cms.Template, java.lang.String)
must
first be called to actually add the template to.
section
- the content section where the template residestype
- the content type to which the template belongstemplate
- the template which will be made defaultcontext
- the use context in which the template will be made defaultpublic Template getTemplate(ContentItem item, String context)
item
- the content itemcontext
- the use context for the template, such as "public" or
"abridged".
public TemplateCollection getTemplates(ContentItem item)
item
- the content item
TemplateCollection
of all the templates assigned
to the itemgetUseContexts(com.arsdigita.cms.ContentItem)
public TemplateCollection getUseContexts(ContentItem item)
getTemplates(ContentItem)
, the collection returned
by this method will include all use contexts for an item, even
those use contexts to which no template is yet assigned.
item
- the content item
TemplateCollection
of all the templates assigned
to the itempublic com.arsdigita.cms.ItemTemplateCollection getContextsWithTypes(ContentItem item)
public Template getDefaultTemplate(ContentSection section, ContentType type, String context)
section
- the content section to which the template belongstype
- the content type to which the template belongscontext
- the use context for the template, such as "public" or
"abridged".
public Template getDefaultTemplate(ContentSection section, ContentType type, String context, com.arsdigita.mimetypes.MimeType mimeType)
section
- the content section to which the template belongstype
- the content type to which the template belongscontext
- the use context for the template, such as "public" or
"abridged".mimeType
- The mime type of the template that is desired.
public TemplateCollection getTemplates(ContentSection section, ContentType type)
section
- the content sectiontype
- the content type
public TemplateCollection getTemplates(ContentSection section, ContentType type, String context)
section
- the content sectiontype
- the content typecontext
- the use context
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |