Discussion:
Magnolia CMS: Getting a node type in freemarker
adrien beber (via Magnolia Forums)
2014-02-27 16:04:48 UTC
Permalink
If I have a node of type javax.jcr.Node, I usually do:

[code][#assign nodeType = myCoolJcrNode.getProperty("jcr:primaryType").getValue().getString()][/code]

If I have a node of type info.magnolia.jcr.util.ContentMap, similarly I will do:

[code][#assign nodeType = cmsfn.asJCRNode(myCoolContentMap).getProperty("jcr:primaryType").getValue().getString()][/code]


Any quicker/cleaner way to do this?

Thanks
--
Context is everything: http://forum.magnolia-cms.com/forum/thread.html?threadId=a752b982-f9e1-45ca-b9d1-e921a8e141ea


----------------------------------------------------------------
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: <user-list-***@magnolia-cms.com>
----------------------------------------------------------------
M***@public.gmane.org
2014-02-28 14:41:56 UTC
Permalink
Use this:

${myCoolContentMap["jcr:primaryType"]}

It also works for any variable, property name.

Marvin Kerkhoff
Manager Content Solutions
Certified Magnolia Developer
-------------------------------------------------
arvato systems Schweiz AG
Technoparkstrasse 1
8005 Zürich

-----Ursprüngliche Nachricht-----
Von: user-list-***@magnolia-cms.com [mailto:user-list-***@magnolia-cms.com] Im Auftrag von adrien beber (via Magnolia Forums)
Gesendet: Donnerstag, 27. Februar 2014 17:05
An: Magnolia User List
Betreff: [magnolia-user] Magnolia CMS: Getting a node type in freemarker

If I have a node of type javax.jcr.Node, I usually do:

[code][#assign nodeType = myCoolJcrNode.getProperty("jcr:primaryType").getValue().getString()][/code]

If I have a node of type info.magnolia.jcr.util.ContentMap, similarly I will do:

[code][#assign nodeType = cmsfn.asJCRNode(myCoolContentMap).getProperty("jcr:primaryType").getValue().getString()][/code]


Any quicker/cleaner way to do this?

Thanks
--
Context is everything: http://forum.magnolia-cms.com/forum/thread.html?threadId=a752b982-f9e1-45ca-b9d1-e921a8e141ea


----------------------------------------------------------------
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: <user-list-***@magnolia-cms.com>
----------------------------------------------------------------



----------------------------------------------------------------
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: <user-list-***@magnolia-cms.com>
----------------------------------------------------------------
Loading...