Hi Nils,


On Nov 17, 2009, at 12:43 PM, Nils Breunese wrote:


Hello,

I have created a custom statistics module, which seems to work fine. The last piece of the puzzle is automatically including a FreeMarker template in all pages. For now I have just added an include to / templating-kit/templates/main, which works fine, but I would like my module to be a module that 'just works' for all sites when installed, so I'd rather not have to modify main.ftl manually after installing my module. At the same time I'd rather not modify main.ftl if this is not necessary, since that would mean I'd have to check if I need to update my module every time STK is updated.

What is the recommended way to solve this? I see two options:

1) Have my module replace main.ftl with a version that includes the include for my statistics template. How should I do this exactly?

2) Change the Site Definitions -> default/templates/prototype/ templatePath to point to a modified version of main.ftl which I could store as /<my-module>/templates/<my-module>.ftl. (Of course I would still need to check this template when new versions of STK are released.) Should I change the reference, export the XML and add this to my module's bootstrap files or should I modify this reference programmatically? Since we're using EE, I might have to loop over all site definitions, and new site definitions added after the module is installed, would still need to be modified manually?

In both cases, you'll need to work things out with a version handler:
  
http://documentation.magnolia-cms.com/reference/custom-module.html#Moduleversionhandling

To update site definitions:
 info.magnolia.module.templatingkit.setup.UpdateAllSiteDefinitions
.. unfortunately, this will indeed not modify site definitions that might be added after your module; on the other hand, seems to me like the important thing is that your module can be dropped on an existing instance and put into action. Whatever other site definition are added afterwards should probably just "know" that they want to use your module or not.

To replace the template itself, you could have a look at info.magnolia.module.inplacetemplating.setup.TemplatesInstallTask in the inplace-templating module.


Or is there another, maybe even better, way of accomplishing this include?

Better, I don't know, but certainly a different approach: have you considered using SiteMesh ?

hth,

-g


----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/home/community/mailing-lists.html
To unsubscribe, E-mail to: <[email protected]>
----------------------------------------------------------------

Reply via email to