6 Replies Latest reply on Oct 17, 2011 7:34 PM by Mak-Oracle

    Datafile in replaceable region - external application 11g


      I am having a problem with secondary page templates. I need to access the metadata from the datafile assigned to the replaceable placeholder.

      When i do ${wcmContext.section.primaryLayout.placeholders} i get the map with placeholder names and datafiles, region definitions, etc...

      But, when i do ${wcmContext.section.secondaryLayout.placeholders} i simply get an empty map ({}). I guess that is because this method does not get into account the dynamic assignation of a dataFile to the placeholder.

      ¿Is there any workaround so i can get the dynamic metadata? I may get the dDocId from the request uri, but I see it as the last resource to solve this.

      Thanks in advance.
        • 1. Re: Datafile in replaceable region - external application 11g
          Did you get any resolution on this issue? I would like to do the same thing and was wondering how you solved it.
          • 2. Re: Datafile in replaceable region - external application 11g
            By definition, there is nothing assigned to the secondary placeholder. It will never work this way.
            • 3. Re: Datafile in replaceable region - external application 11g
              So the way I am determining the datafile name is by using the url string. Our primary pages use */index.html* and our secondary pages use */some-datafile.html* where some-datafile is the content id of the datafile. It took me a considerable amount of time to figure out the call to make as documentation on jstl is very limited and high level at best. Here is my logic:

              <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
              <%@ taglib uri="http://www.oracle.com/jsp/wcm" prefix="wcm"%>
              <%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
              <c:set var="_dataFile" value="" />
              <c:set var="_forwarduri" value="${fn:split(requestScope['javax.servlet.forward.request_uri'],'/')}" />
              <c:forEach items="${_forwarduri}" var="el" varStatus="elstatus">
              <c:if test="${elstatus.last && el != 'index.html'}">
              <c:set var="_dataFile" value="${fn:substringBefore(el,'.html')}" />

              The above code will print the content id to the browser window. You can then use the _dataFile variable to get the metadata like this:

              <wcm:metadata contentID="${_dataFile}" var="metadata" />
              <c:forEach items="${metadata.resultSets.DOC_INFO.rows}" var="metadatarow">
              <c:if test="${fn:trim(metadatarow.xMetaTitle) != ''}">
              <c:set var="_metatitle" value="${metadatarow.xMetaTitle}" />
              <c:set var="_metakeyw" value="${metadatarow.xKeywords}" />
              <c:set var="_metadesc" value="${metadatarow.xDescription}" />

              Of course, the code here is incomplete as you would need to add logic to handle the primary template datafile that holds your metadata. If anybody can think of a better way to do this, please speak up :-)

              Edited by: 890223 on Oct 10, 2011 6:29 AM
              • 4. Re: Datafile in replaceable region - external application 11g

                Simplest way to get the metadata fields in secondary page is following. It will create a variable for metadata file.

                <wcm:metadata contentID="${wcmContext.placeholder.dataFile}" var="metaDataVar"/>

                Now you can access any metadata field via below:


                Let me know if it works for you?

                • 5. Re: Datafile in replaceable region - external application 11g
                  That only works when a dataFile is explicitly set in the site structure. When you are using a secondary template with a replaceable region, then the dataFile is passed in dynamically and must be retrieved in another way. The only way I found that works is to grab it from the URL. There is probably a simpler way, but documentation on the matter is sparse and high-level at best.

                  In other words, the primary page might be /some-section/index.html but the secondary page would be /some-section/article-about-something.html where article-about-something is the Content ID of your dataFile. And because that dataFile is passed in dynamically through the URL, it is not part of wcmContext.placeholder.
                  • 6. Re: Datafile in replaceable region - external application 11g

                    Give a shot and then let me know.

                    I have worked on primary and secondary combination, with the same url concept as you mentioned. Its working man.