Re: template_list Digest, Vol 8, Issue 3

Kevin <[email protected]> Wed, 30 Jan 2008 09:49:44 -0500
Newsgroups gmane.comp.cms.jahia.template
Message-ID <[email protected]>
Hi Benjamin,

Thanks for the reply.
I meant to post a follow up yesterday but life got in the way.

Actually, you are spot on. That did the trick. It's just the
documentation didn't indicate that approach and I guess I've been
spending too much time in the MVC world that pageContext is not
something I've used as much lately. I don't do scriptlets.

For anyone who might benefit from this, here's a code snippet of how
one might pull data from a container located several layers deep.

This uses the getLightContainerLists method that the documentation
indicates performs better. Unfortunately, there's not taglib for this
(that I can see). Jahia needs to pick up the pace on this so we can
minimize our use of scriptlets (not a best practice).

<%
// not so fun jahia api here
SiteBean currentSite = (SiteBean) pageContext.findAttribute("currentSite");
List allNewsLists = currentSite.getLightContainerLists("fooContainerList");
for (Iterator iter = allNewsLists.iterator(); iter.hasNext();) {
	ContainerListBean containerListBean = (ContainerListBean) iter.next();
	List myContainerList = containerListBean.getContainers();
	//System.out.println("myContainerList size = " + myContainerList.size());
	// for us, we only allow one instance of fooContainerList, grab the first one
	ContainerBean containerBean = (ContainerBean)myContainerList.get(0);
	// ugly here, just a proof of concept
	%>
	title=<%=containerBean.getFieldValue("mTitle")
%>,summary=<%=containerBean.getFieldValue("mSummary") %>
	<%
	//System.out.println("mTitle = " + containerBean.getFieldValue("mTitle"));
	//System.out.println("mTitle = " + containerBean.getFieldValue("mSummary"));
}
%>
_______________________________________________
template_list mailing list
[email protected]
http://lists.jahia.org/cgi-bin/mailman/listinfo/template_list