« Back

Grabbing Asset Tag through Wiki ADT

Technical Blogs February 27, 2014 By Travis Cory Staff

Liferay 6.2 brings the era of the application display template (ADT) into full swing. There have been some awesome posts about how to use the ADT. For more information about ADT see this page, this page, this page, etc.


Right, right, sorry, as you can see, there are many uses of ADT. It allows you to write a new template for a portlet so that it is displayed in whatever manner you like. This can be acheived through the use of Freemarker, or Velocity. Today I will show you a ADT I created for the Wiki portlet using Freemarker.

The Task

As with any asset, it is possible to "tag" an entry. This allows a user to see all organize and navigate through assets based on tags. What if you wanted to have a different way to display a wiki page if it had a specifc tag. What if you wanted to grab just one tag and create a new layout for the wiki based on the tag? What if I told you this was possible with ADT?



Mission Possible

So I set off to make myself a fancy ADT. I borrowed from the Social Wiki ADT to make sure I was calling all the macros right. This is important so that you do not lose your icons.  We will use the tag "cat-meme" to demonstrate our ADT. So first lets create three wiki pages, one with just the tag "cat-meme", one with two tags, and one without the tag "cat-meme".


Now it is time to apply the ADT to our page. Hold on tight!




The Results

Here are the results of our ADT!


As you can see, the pages that have the tag "cat-meme" receive separate styling than the pages without tags. If you wanted to use multiple tags you can use  <#elseif tags?seq_contains("[tag-name]")> .


The exact code I used is shown below. Thanks for reading, happy ADT-ing!




Threaded Replies Author Date
very cool!! Wilson Man February 27, 2014 4:50 PM

Posted on 2/27/14 4:50 PM.