On Mar 6, 2008, at 1:31 AM, Patrick Aebischer wrote:

Hi

Ryan Gardner wrote:
I'm trying my best to figure out how to get the data out of a data module and into the page...


check the <cms:query> tag. I didn't tried it but it could work:

http://dev.magnolia.info/ref/latest/magnolia-taglib-cms/ tagreference.html#query


Good luck,

  Patrick

Yes, it was actually the first thing I tried - but I think I was up too late when I tried it the first time because I had a typo in the EL where I was trying to get the data out of the query results! :) (friends don't let friends code drowsy)

Here's what I am using now that works just fine:

-----
<cms:query var="businesses" nodeType="business" repository="data" query="${businessDirQuery}" />

<c:if test='${empty businesses }' >
    <h2>No business found for this category / region</h2>
</c:if>

<c:forEach var="businessNode" items="${businesses}">
    <cms:setNode  var="business" contentNode="${businessNode}" />
<jsp:directive.include file="../data-decorators/business- directory-entry.jspf"/>
</c:forEach>

------
I'm using the jsp:directive.include to let me split off the part that does the decoration of the data nodes in a similar way to how paragraph templates work. The setNode is invaluable because it exposes a map of all the attributes.

The only strange thing I noticed was that my field "phoneNumber" was giving me a number format exception when it was being rendered - which is strange since it is stored as a string! The easy workaround is to just use <c:out value="${phoneNumber} " /> (with the extra space after the phone number variable to force it to concatenate the phone number with a blank space and therefore treat it as a String...)

In any case - the easiest way to get data out of the data module seems to be:
1. Use the cms:query
2. Use the cms:setNode to expose the data's properties in a map

and in my case, splitting out the "template" that renders those things into a separate file.

Ryan



----------------------------------------------------------------
for list details see
http://documentation.magnolia.info/docs/en/editor/stayupdated.html
----------------------------------------------------------------

Reply via email to