Terry, I am no expert, but;
01. The site model really only applies to the front page as there are methods that do not relate to individual weblogs. 02. In roller.properties, models/classes are made available by the configs: # Set of models to be made available for weblog page rendering rendering.pageModels=\ org.apache.roller.weblogger.ui.rendering.model.PageModel,\ org.apache.roller.weblogger.ui.rendering.model.ConfigModel,\ org.apache.roller.weblogger.ui.rendering.model.UtilitiesModel,\ org.apache.roller.weblogger.ui.rendering.model.URLModel,\ org.apache.roller.weblogger.ui.rendering.model.MessageModel,\ org.apache.roller.weblogger.ui.rendering.model.CalendarModel,\ org.apache.roller.weblogger.ui.rendering.model.MenuModel # Set of models to be made available for weblog feed rendering rendering.feedModels=\ org.apache.roller.weblogger.ui.rendering.model.FeedModel,\ org.apache.roller.weblogger.ui.rendering.model.ConfigModel,\ org.apache.roller.weblogger.ui.rendering.model.UtilitiesModel,\ org.apache.roller.weblogger.ui.rendering.model.URLModel,\ org.apache.roller.weblogger.ui.rendering.model.MessageModel # Set of models to be made available for weblog search rendering rendering.searchModels=\ org.apache.roller.weblogger.ui.rendering.model.SearchResultsModel,\ org.apache.roller.weblogger.ui.rendering.model.ConfigModel,\ org.apache.roller.weblogger.ui.rendering.model.UtilitiesModel,\ org.apache.roller.weblogger.ui.rendering.model.URLModel,\ org.apache.roller.weblogger.ui.rendering.model.MessageModel,\ org.apache.roller.weblogger.ui.rendering.model.CalendarModel,\ org.apache.roller.weblogger.ui.rendering.model.MenuModel # Set of models to be made available for weblog page *preview* rendering # NOTE: this *does* have some differences between the pageModels rendering.previewModels=\ org.apache.roller.weblogger.ui.rendering.model.PreviewPageModel,\ org.apache.roller.weblogger.ui.rendering.model.ConfigModel,\ org.apache.roller.weblogger.ui.rendering.model.UtilitiesModel,\ org.apache.roller.weblogger.ui.rendering.model.PreviewURLModel,\ org.apache.roller.weblogger.ui.rendering.model.MessageModel,\ org.apache.roller.weblogger.ui.rendering.model.CalendarModel,\ org.apache.roller.weblogger.ui.rendering.model.MenuModel # Set of page models specifically for site-wide rendering rendering.siteModels=\ org.apache.roller.weblogger.ui.rendering.model.SiteModel,\ org.apache.roller.weblogger.ui.rendering.model.PlanetModel 03. The servlets are the entry points, in PageServlet checkout the code around line #374, which sets up the velocity context via the ModelLoader classes for the main pages. If the Weblog is the frontpage the rendering.siteModels are made available also. 04. The model classes in org.apache.roller.weblogger.ui.rendering.model implement interface Model which has a method getModelName(), This this is the name that you use in the templating. eg : If you create a new MyModel (implementing Model), and then in getModelName() return 'myModel'. Then in roller.properties add the class MyModel: # Set of models to be made available for weblog page rendering rendering.pageModels=\ .... org.apache.roller.weblogger.ui.rendering.model.CalendarModel,\ org.apache.roller.weblogger.ui.rendering.model.MenuModel\ org.apache.roller.weblogger.ui.rendering.model.MyModel Then in the templating you can use $myModel.getxxx If you place your code in the SiteModel (getModelName() == 'site') then you must use $site.getxxx and then in the PageServlet make sure the rendering.siteModels are loaded for ALL weblogs. If your method myMethod relates to the whole site then probably best to put it SiteModel, but if you want to call it in a normal weblog it would be better to add it to the PageModel and not load the SiteModel for all weblogs. Hope this helps. Cheers Greg Terry Corbet <[email protected]> 05/03/2009 18:58 Please respond to [email protected] To [email protected] cc Subject RE: The Missing Manual I guess my reply ought to be, "Thanks, so much", and, indeed, I am very appreciative of your help, but can you help me understand: 01. Why would there be some restriction concerning what functionality would be limted to what templates? 02. Assuming the architects have some idea concerning security, it still must be the case that such a 'rule' is implemented somewhere in a public API over which I, as someone wanting to use the API, need to have control. Can you tell me where to find the 'hooks' and where to read something to explain how to control them? 03. Did I get into such a restriction because I mistakenly thought that I could just get by by adding functionality to SiteModel? Would such a restriction to 'Front Page' go away if I took the additional steps necessary to create an entirely new Model? 04. If myMethod is coded into the SiteModel and your suggestion is to invoke it using Velocity's $model in lieu of $site, then I really need to understand how/where the mapping between Velocity naming and Java class naming takes place. Can you tell me where to find that? Share our environment commitment - conserve resources and contribute to the reduction of CO2 emissions by not printing the email unless absolutely necessary to do so. Any opinions expressed are those of the author, not Ricoh UK Ltd. This communication does not constitute either offer or acceptance of any contractually binding agreement. Such offer or acceptance must be communicated in writing. It is the responsibility of the recipient to ensure this email and attachments are free from computer viruses before use and the sender accepts no responsibility or liability for any such computer viruses. Ricoh UK Ltd. may monitor the content of emails sent and received via its network for the purpose of ensuring compliance with its policies and procedures. This communication contains information, which may be confidential or privileged. The information is intended solely for the use of the individual or entity named above. If you are not the intended recipient, be aware that any disclosure, copying, distribution or use of the contents of this information is prohibited. If you have received this communication in error, please notify the sender immediately by return email with a copy to [email protected] . Please contact us on +44 (0) 208 261 4000 if you need assistance. Registered in England No: 473236 VAT No: GB524161280
