On Sun, Jan 18, 2009 at 2:39 PM, Emmanouil Batsis (Manos) <[email protected]> wrote: > Emmanouil Batsis (Manos) wrote: >> >> Emmanouil Batsis (Manos) wrote: >>> I'm trying to render menu as a list of all blogs in a custom template. >>> AFAIK there is no easy method to obtain the list of blogs from the >>> site model, so I thought reusing the _blogdirectory.vm code for this. >>> It doesn't work though; the anchor links (first letter) appear in my >>> template, but not the list of blogs below it. >> >> To be a bit more precise, $site.getWeblogsByLetterPager($chosenLetter, >> -1, $pageLength) always returns an empty pager. > > The easiest way I could figure out to create my menu is something like the > code bellow.
The best approach is probably to introduce a new model to be used in the template. For example, you could create a new model "MyModel" that supports a method "getAllWeblogs()". You could then call the Weblog.getWeblogs() method to return a list of all weblogs. There is an example of how to create a new model in the directory apps/weblogger/docs/examples/plugins. And by the way, for the models we create for Roller, which are intended for use by end users, we usually follow a couple patterns: 1) Pager: we don't allow users to obtain giant lists of all objects of a given type. Instead, we offer a Pager interface so that users can create pageable displays of objects. 2) Wrapper: won't don't allow users to object the raw POJO objects used in Roller because we want to to be able to escape some fields, hide paswords, etc. We have an existing wrapper class for Weblog objects, so if you are returning Weblog objects from your model, then you should use it. If your model is to be used only in the site-wide blog and accessed only by administrators of the system, then perhaps those patterns are not so important to you. Hope that helps. - Dave
