tags:

views:

25

answers:

1

Hi All,

I am working on a dotCMS project where we are writing HTML, Javascript and Velocity - but no Java (there has been no need yet).

In dotCMS, I need to traverse two relationships to come up with a list of all items of Structure C related to an instance Structure A where Structure A relates to Structure C which relates to Structure D. Fine, I have done this and have a list of content that I can iterate through: http://pastebin.com/52uStcUA.

The problem is that I need to paginate this list and the #pageContent() macro only accepts a query, not a list. I looked into the source of the #pageContent() macro in dotCMS_library.vm and found that it calls to Java: ContentsWebAPI.pageContent() - which in turn only accepts a query.

As far as I can see, this leaves me with two options:

1) Somehow phrase a query for the #pageContent() macro that expresses traversal of a transitive relationship. I know how to write a query for one relationship (http://pastebin.com/cwLY0Av4) but not two.

2) Write my own Java implementation of ContentsWebAPI.pageContent(), which frankly sounds like overkill (and perhaps just the first step down a long and painful road).

So, any other ideas on how to solve this? Any feedback would be appreciated!

Rob :)

A: 

It should be fairly easy to write the paging logic you need in velocity - the $list in Velocity is just a java.util.ArrayList.

A helpful tool that is included in dotCMS is the $listTool see: http://velocity.apache.org/tools/releases/velocity-tools-1.2/javadoc/org/apache/velocity/tools/generic/ListTool.html

This can give you specific items in your list. All you need are some variables like $page, $numShow, etc... You can pass around the $page variable in the url and use it to get sublists, etc...

Will Ezell