Simplest dotCMS Detail Page using Velocity
Update: 27/10/2010 Used
Simplest way to create a dotCMS detail page in Velocity. All you need is the item's
This produces a non-sorted list of attribute name/value pairs. For a more complicated detail page (which is sorted), try out this code sample by Chris Falzone, which he referred me to in this dotCMS Yahoo post: loop through all fields in a node?
You can useIt is most important to use a method that relies on The
One more thing: right now, I can find no concrete documentation on either
$webapi.getIdentifierInode($id)
to ensure that we have identifier
, irrespective of whether our request parameter was an identifier
or inode
.Simplest way to create a dotCMS detail page in Velocity. All you need is the item's
identifier
or inode
. Assume identifier
is stored as id
in the request.#if(!$UtilMethods.isSet($request.getParameter("id"))) <p> Nothing to fetch </p> #else #set($id = $request.getParameter("id")) #set($id = $webapi.getIdentifierInode($id)) ## Get identifier from inode or identifier #getContentMapDetailByIdentifier($id) #foreach($entry in $content.entrySet()) <p><b>$entry.key</b>: $entry.value</p> #end #end
This produces a non-sorted list of attribute name/value pairs. For a more complicated detail page (which is sorted), try out this code sample by Chris Falzone, which he referred me to in this dotCMS Yahoo post: loop through all fields in a node?
You can use
#getContentMapDetailByIdentifier()
or #getContentMapDetail()
- they seem to do pretty much the same thing. identifier
rather than inode
(like #pullContent()
) for lookup because users might bookmark the detail page and inode
changes with each revision.#getContent()
and #pullContent()
macros can use either the identifier
or any of the inode
values - they are smart enough to always look up the latest content (but they don't return a handy map though).One more thing: right now, I can find no concrete documentation on either
#getContentMapDetailByIdentifier()
or #getContentMapDetail()
, just a couple of posts that reference those methods. I had to dig into dotCMS vm files (dotCMS 1.7). Both of these macros are defined in $DOTCMS_HOME/dotCMS/WEB-INF/velocity/VM_global_library.vm
.