Loading presentation...

Present Remotely

Send the link below via email or IM


Present to your audience

Start remote presentation

  • Invited audience members will follow you as you navigate and present
  • People invited to a presentation do not need a Prezi account
  • This link expires 10 minutes after you close the presentation
  • A maximum of 30 users can follow your presentation
  • Learn more about this feature in our knowledge base article

Do you really want to delete this prezi?

Neither you, nor the coeditors you shared it with will be able to recover it again.


Advanced Templates in dotCMS.

No description

Mark Watkinson

on 18 April 2014

Comments (0)

Please log in to add your comment.

Report abuse

Transcript of Advanced Templates in dotCMS.

Status Update
like comment share
TIL: How to load content in a widget
Shared a Link: lucene.apache.org
like comment share
A query language with very specific and nonsenscal rules
Velocity Code

Basic Notes
Executed on the dotCMS server
Run once on load
No user interaction
No events
Can output as plain text anywhere within the HTML for a page
Pass variables into javascript/HTML
Velocity Widgets and you.
Advanced Templates in dotCMS.

Basic Syntax
$variables (and tools)
${variableWithBoundry}other text can follow
Common Velocity macros and reserved variables: http://doradusweb.com/wp-content/uploads/2009/09/dotCMSCheatSheet.pdf
Java classes mapped to velocity Variables
$text - com.dotmarketing.viewtools.LanguageWebAPI (String functions)
Beware of naming of structure variables
Common Tools and reserved variables
$request - request object + session via .getSession()
$math - Java math funtions
$dotcontent - access to dotCMS content
$date - Java data functions
Every Basic template references a theme.
Stored in /application/themes/<theme name> in site browser
That theme must contain template.vtl in its root
Template.vtl may parse additional files (header.vtl, footer.vtl, head.vtl) via #dotParse("${dotTheme.path}header.vtl")
Advanced Templating: Theme VTL files
$dotThemeLayout tool used to reference individual template settings
.header, .body, .rows, .column, .footer and so forth.
Edit with care. Shared between ALL pages that reference the template.
Generally only one template per host.
May even be shared between hosts.

A Widget it is a reusable, self contained block of velocity code and HTML
Similar to contents of a container
Can replicate container behavior with appropriate code
Stored in .vtl files anywhere in the host (/widgets/ by default)
Can be included in a page in a number of ways
Advanced templating: Widgets
Including a 'raw' vtl widget
Save .vtl widget code to a file in the host
In container code, or any other vtl code use $dotParse('<pathToVTLFile>')
Packaging a .vtl file as a Widget
Save .vtl widget code to a file in the host
Create a new Simple Widget content type
Include a title
use $dotParse('<pathToVTLFile>') as the code
It is also possible to write the VTL code in code field directly
Adding a widget to a page
Create a container with the following code:
Include the container on the desired template
Browse to the page in edit mode
Click Add Content --> Add Widget on the appropriate section of the page
Select simple widget and search for the widget
Click select to add the widget to the container
Four methods.
Pull content: $dotcontent.pull()
Pull paged content: $dotcontent.pullperPage()
JSONContent + ajax: /JSONContent/
Find by (known) inode: dotcontent.find()
Variable differences depending on fetch method (container, pull/find, JSONContent)
Pull content: $dotcontent.pull(query, count, sort)
query: uses a lucene query string
count: provide maximum 0 for all
sort: a named variable to sort on, ascending or descending.
$dotcontent.pull("+structureName:DfBlogEntry", 0, "DfBlogEntry.published desc")
Pull Paged content:
$dotcontent.pullPerPage(query, pageNum, perPage, sort)
query: uses a lucene query string
pageNum: page of results to pull
perPage: maximum results per page
sort: a named variable to sort on, ascending or descending.
$dotcontent.pullPerPage("+structureName:DfBlogEntry", 2, 5, "DfBlogEntry.published desc")
Ajax server available at <dotCMS host>/JSONContent/?
loaded in javascript, unavailable to velocity code.
type: json or xml datatype for response
q=: uses a lucene query string
limit: provide maximum 0 for all
offset: number of results to skip (for example for pagination)
orderBy: a named variable to sort on, ascending or descending.
JSONContent example (javascript)
${esc.d}(document).ready(function() {
url: '/JSONContent/',
data: 'type=json&q=' + query + '&offset=' + offset + '&limit=' + count + '&orderBy=' + sort
dataType: 'json',
success: function(data) {
${esc.d}.each(data.contentlets, function(i, contentlet) {
//extract vatiables from contentlet, write html out to page using javasdscript
Takes the general format of <+,-><variable:value>< ><+,-><variable:value>...
URL format example:
Or in plain text:
+structureName:DfBlogEntry +languageId:1 +BDfBlogEntry.published:[20140310 TO 20140401]
Give me content for the structures called DfBlogEntry with language ID of 1 (US english) with a pubilshed date between march 10 and April 1 2014
Powerful but tetchy.

Find by a known INode
inode: a unique identifier assigned to every item in dotCMS
content, image, vtl file, everything
Occasionally you will find a variable contains a inode rather than the content you seek directly
Use dotcontent.find to retrieve the actual content item.
Posted a Image: Categories & Tags
like comment share
Tags are user entered searchable values
Categories are administrator entered and can have additional associated categories in a tree and even variables of their own.
Posted a Image: Copying a Host
like comment share
There are special rules to be aware of when duplicating a host.
Most of these are regarding the host/folder field on a content item
Specified host: content is to be duplicated
System host or no host field: content is to be shared across hosts
Full transcript