Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
Predefined variables in Velocity templates
Hi,
I'm using the Journal CMS with articles. Since I've used Velocity before, I'd like to use this as the template engine.
I've created a custom structure, and correctly associated it with a corresponding VM template.
But I'm unable to find in the documentation, or in the source code, the name of the predefined variables which can be accessed in the template.
To be more specific:
My custom structure has two fields: subtitle and draft(boolean) .
I can access and display them in a VM template ina straightforward manner:
$subtitle.Data
$draft.Data
but how can I access the other, standard, attributes of an article, such as the title, the date, the expiring date, and so on?
$title.Data
does not work..
Can anybody point out to me where to look for such names? Documents, source code, examplese.. anything
Thanks in advance,
Walter
I'm using the Journal CMS with articles. Since I've used Velocity before, I'd like to use this as the template engine.
I've created a custom structure, and correctly associated it with a corresponding VM template.
But I'm unable to find in the documentation, or in the source code, the name of the predefined variables which can be accessed in the template.
To be more specific:
My custom structure has two fields: subtitle and draft(boolean) .
I can access and display them in a VM template ina straightforward manner:
$subtitle.Data
$draft.Data
but how can I access the other, standard, attributes of an article, such as the title, the date, the expiring date, and so on?
$title.Data
does not work..
Can anybody point out to me where to look for such names? Documents, source code, examplese.. anything
Thanks in advance,
Walter
Interesting point. The code that stuffs all the variables into the CMS velocity template is com.liferay.portlet.journal.util.JournalVmUtil.transform(). And I believe all thoese tokens are there as well. Take a look at the variables in com.liferay.portlet.journal.model.JournalStructure. They are grabbed just before the transform occurs.
Alexander Chow:
Interesting point. The code that stuffs all the variables into the CMS velocity template is com.liferay.portlet.journal.util.JournalVmUtil.transform(). And I believe all thoese tokens are there as well. Take a look at the variables in com.liferay.portlet.journal.model.JournalStructure. They are grabbed just before the transform occurs.
Thank you, problem solved!!!
I;ve seen the classes you have pointed out. Unfortunately JournalVmUtil just seems to put in the context of the VM page the dynamic elements, i.e. the fields I' ve added to the base article.
But, despite the oddly looking names, the JournalStructure holds the names of the default attributes of the articles!!!
I've tried putting in my template the line:
$reserved-article-title.Data
and it spits out the .. article Title
I'd suggest a different naming (and a small help) should, well, help, but for the time being, it is just what I was looking for!
Again, thank you so much!
Walter
Community
Company
Feedback