cancel
Showing results for 
Search instead for 
Did you mean: 

accessing content repsitory in WCM

nyronian
Champ in-the-making
Champ in-the-making
I am trying to understand how to access things like images that are placed in the content repository in the WCM forms. 

Below is my situation:

1. I have a ftl template that displays the images from the content repository using the below code:


<#assign child1 = companyhome.childByNamePath["Data Dictionary/Images/RoofHeat/roofheat_blueheat2_thumb.jpg"] >
  <#if child1.isDocument && (child1.mimetype = "image/png" || child1.mimetype = "image/jpeg" || child1.mimetype = "image/gif")>
    <td class="pics"><a href="/alfresco${child1.url}" target="_blank"><img src="/alfresco${child1.url}" width="200" height="126" border="0"/></a></td>
  </#if>

This works just fine and when I preview the "Presentation Template" in the content manager, it looks perfect.

2.  I then added the following code (with an xsd to match)


${Welcome.Welcome_Message}

The plan is to use the xsd to create dynamic content templates and generate them to html.

3.  In the "Create Web Content Wizard" thing seem to work fine.  It reads the xsd, allows me to enter my dynamic content, creates the new xml file, but cannot  create the new merged html file.  I get the following error on the final step of the wizard:




Error generating rendition using index.ftl: freemarker.template.TemplateModelException: Cannot perform an XPath query against an empty node set.

I am assuming it has having a hard time resolving my xpath to my images.  How should I be doing this?  What is different in the environments for it to work fine int the ECM but not in the WCM.  Is XPath different/better/easier?

Thank you in advance.
3 REPLIES 3

nyronian
Champ in-the-making
Champ in-the-making
Just want to make sure my question makes sense.  Can you not access the CMS repository with freemarker when in the WCM?  Am I accessing it wrong?  I can't find any of the examples where resources are pulled from the CMS?  It seems very basic to me and I'm sure I'm doing the template wrong even though it works from the presentation templates.

Please let me know, if it doesn't work then I need to scrap the WCM and build my own on top of Alfresco the does pull content.  Seems like a waste to me though.

Thanks in advance.

arielb
Champ in-the-making
Champ in-the-making
currently rendering engines (including the freemarker engine in wcm) do not provide the same access to variables that the TemplateService provides to freemarker, meaning that the companyhome variable is not available.  this will most likely be made available in 2.1 once we integrate renderingengines into TemplateService.

however, what you can do is place your images in the webproject, not the data dictionary.  note that only the webproject is deployed to your production system, not assets within the data dictionary.

nyronian
Champ in-the-making
Champ in-the-making
Thank you so much for your response Ariel.  It is clear that I need to take a little different approach for my objectives. 

It will be nice to build websites that pull merged xml documents and pulls content and link from/into the repository.