Hi Erando, We had a similar requirement in one of our projects. In our case our site is available in different version for different classes of mobile devices.
Unfortunately, it is not simply a matter of putting in "[#if]" blocks in your templates. That solution will only work if you disable cacheing in magnolia, otherwise the cache module will cache the first version of the page rendered, and subsequent requests will receive this version of the page, even if the requesting browser is a different kind. I can outline the solution we followed: 1. Create a "Filter" for magnolia which will handle your browser detection. In our case we extended the "mobile module" which does browser detection based on the WURFL (http://wurfl.sourceforge.net/backgroundinfo.php) device database. Depending on the browser, we classified the request as either "smartphone", "mobile" or "normal". You could implement any classification you want. The Filter sets the extension in the aggregation state according to the device classification. The Filter is installed fairly early in the magnolia filter chain, before the cache filter. 2. Create a cache-policy by extending info.magnolia.module.cache.cachepolicy.Default and overriding the method retrieveCacheKey() to return a cache-key which takes the extension from the aggregation-state into account. This will enable cacheing different versions of the page for each of your browser classifications. Set up this cache policy on your public instance. 3. Create sub-templates (see magnolia templating documentation) for each of your classifications (except "normal"). In this way the different browsers get served from different templates. The solution works well, and harmonizes well with magnolia's fast cacheing mechanism. The templates can all be edited in magnolia, etc... There is one caveat: Prior to Magnolia version 4.5 the sub-templates mechanism is very nice for the templates, but not so nice for the paragraphs. The paragraphs do not support "sub-templating". We solve this by creating "meta-templates" for the paragraphs which #include different variants based on the extension, like this: [#switch state.extension] [#case "smartphone"] [#include "/mysite/paragraphs/mytemplate_smartphone.ftl" ] [#break /] [#case "mobile"] [#include "/mysite/paragraphs/mytemplate_mobile.ftl" ] [#break /] [#default] [#include "/mysite/paragraphs/mytemplate_normal.ftl" ] [/#switch] In Magnolia 4.5 the templating mechanism will include "template-variants" (the new name for sub-templates) also for paragraphs. Hope that is helpful for you! Regards from Vienna, Richard -----Ursprüngliche Nachricht----- Von: [email protected] [mailto:[email protected]] Im Auftrag von Magnolia Forums (on behalf of Erando) Gesendet: Donnerstag, 22. Dezember 2011 11:01 An: Magnolia User List Betreff: [magnolia-user] Browser specific Paragraphs Hi there, I need to implement some browser specific segments like this paragraph in IE, this one in Firefox, this one in Safari and this one in Google Chrome. This should be achievable easily with JSP but the thing is that I want to edit all of them in the Magnolia no matter which browser the author is using. The problem is that this doesn't match the philosophy of Magnolia since it tears apart the "What you see is what you get" principle. So I'm not sure if the whole thing is possible anyway... Do you maybe have some experience with this issue? Any hint is appreciated as always ;-) Have a nice Christmas time. -- Context is everything: http://forum.magnolia-cms.com/forum/thread.html?threadId=1eb0645c-81aa-4ed1-979e-b846152c7a38 ---------------------------------------------------------------- For list details, see http://www.magnolia-cms.com/community/mailing-lists.html Alternatively, use our forums: http://forum.magnolia-cms.com/ To unsubscribe, E-mail to: <[email protected]> ---------------------------------------------------------------- ---------------------------------------------------------------- For list details, see http://www.magnolia-cms.com/community/mailing-lists.html Alternatively, use our forums: http://forum.magnolia-cms.com/ To unsubscribe, E-mail to: <[email protected]> ----------------------------------------------------------------
