Hi Nils,
On Nov 19, 2009, at 5:11 PM, Nils Breunese wrote:
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.
I have added a version handler to my module which extends
DefaultModuleVersionHandler and implements the getExtraInstallTasks
as follows:
----
protected List getExtraInstallTasks(InstallContext ctx) {
List tasks = new ArrayList();
tasks.add(new TemplatesInstallTask("/vpro-sitestat/.*\\.ftl",
true));
tasks.add(new UpdateAllSiteDefinitions("Prototype template path
update", "Changing prototype templatePath for all site definitions") {
@Override
protected void updateSiteDefinition(InstallContext
installContext, Content siteDefinition) throws RepositoryException,
TaskExecutionException {
final NodeBuilder nodeBuilder = new NodeBuilder(new
TaskLogErrorHandler(installContext), siteDefinition,
getNode("templates/prototype").then(
setProperty("templatePath", "/templating-kit/
templates/main.ftl", "/vpro-sitestat/templates/main-with-
sitestat.ftl")
)
);
nodeBuilder.exec();
}
});
return tasks;
}
----
I cleaned out my repository and restarted Magnolia. The
TemplatesInstallTask succeeds (I see them in the repository), but
the UpdateAllSiteDefinitions task fails with the following error
message:
----
ERROR info.magnolia.module.InstallContextImpl : > Could
not install or update vpro-sitestat module. Task 'Prototype template
path update' failed. (PathNotFoundException: config)
info.magnolia.module.delta.TaskExecutionException: Could not execute
task: config
at
info
.magnolia
.module
.delta.AbstractRepositoryTask.execute(AbstractRepositoryTask.java:60)
(...)
----
I don't really understand this PathNotFoundException and why it's
referring to 'config'. Any ideas?
Hmm, by looking at the source of UpdateAllSiteDefinitions, it's
failing at either line 76 or 82, ie:
Content stkSiteDefinition = modulesNode.getContent("standard-
templating-kit").getContent("config").getContent("site");
or
Content sitesNode = modulesNode.getContent("extended-
templating-kit").getContent("config").getContent("sites");
This would mean that either of /modules/standard-templating-kit/config
or /modules/extended-templating-kit/config is not present on your
instance ... ?
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 ?
I know SiteMesh from my recent experiments with Grails, since
SiteMesh is integrated in Grails. Introducing SiteMesh into our
Magnolia stack just for this feature sounds like overkill, but yes,
I guess it could work. Do you have any experience with/examples of
using SiteMesh with Magnolia?
No, but I've had the itch for a while ;)
We also have a much simpler "instream-modification" module/filter
which could be used for that sort of thing too (it's in enterprise at
the moment, and unreleased)
Cheers,
-g
----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/home/community/mailing-lists.html
To unsubscribe, E-mail to: <[email protected]>
----------------------------------------------------------------