GX WebManager 9.5 is released today and I will write some blog posts to elaborate a bit more on the new features for developers in 9.5. So you’ll not only hear our marketing department say how cool every feature is, but also see that things actually work :- ).
In this post I’d like to take a look at some new additions to the GX WebManager content API. This content API is becoming increasingly powerful and the following examples will hopefully prove this.
It’s only one function, but currently it’s one of the most powerful functions in the content API. With this function you can retrieve media items based on a range of selection and sorting criteria. Before 9.5 there were several ways to retrieve media item content, but they were not bundled in a single function.
When looking up the getMediaItems tag in the Javadoc you see that it’s basically a media collection element, at least it contains many of its fields and functions.
So let’s create an example with getMediaItems(). One thing that’s now a piece of cake is creating a tag cloud, or Folksonomy as you Web 2.0 gurus might say. To create this example simply paste the code below in the mediaItemContent.jspf template:
<br/><br/>
<h2>Tags</h2>
<c:if test="${not empty mediaItem && not empty mediaItem.current}">
<c:set var="termsString" value="" />
<c:forEach var="term" items="${mediaItem.current.terms}">
<%-- retrieve the media Items based on this term --%>
<wm:getmediaitems var="mediaItemResult" andterms="${term.name}" excludemediaitemids="${mediaItem.id}" />
<c:set var="addToTermsString" value="<a href=\"javascript:;\" style=\"font-size: ${10+(2*fn:length(mediaItemResult))}pt; \">${term.name}</a>" />
<c:choose>
<c:when test="${empty termsString}">
<c:set var="termsString" value="${addToTermsString}" />
</c:when>
<c:otherwise>
<c:set var="termsString" value="${termsString}, ${addToTermsString}" />
</c:otherwise>
</c:choose>
</c:forEach>
${termsString}
</c:if>
<br/><br/><br/>
<h2>Related articles</h2>
<c:if test="${not empty mediaItem && not empty mediaItem.current}">
<c:set var="termsString" value="" />
<DL>
<c:forEach var="term" items="${mediaItem.current.terms}">
<c:choose>
<c:when test="${empty termsString}">
<c:set var="termsString" value="${term.name} (${term.id})" />
</c:when>
<c:otherwise>
<c:set var="termsString" value="${termsString},${term.name} (${term.id})" />
</c:otherwise>
</c:choose>
<%-- retrieve the media Items based on this term --%>
<wm:getmediaitems var="mediaItemResult" andterms="${term.name}" excludemediaitemids="${mediaItem.id}" />
<c:if test="${fn:length(mediaItemResult)>0}">
<DT>
tagged with: '${term.name}' (${fn:length(mediaItemResult)})
<br/>
<c:forEach var="mediaItemsWithTerm" items="${mediaItemResult}" varStatus="loopStatus">
<wm:link var="mediaItemLink" linkText="${mediaItemsWithTerm.current.title}" contentid="${mediaItemsWithTerm.id}" />
<DD>${mediaItemLink.htmlTag}</DD>
</c:forEach>
</DT>
</c:if>
</c:forEach>
</DL>
</c:if><br/><br/>
Then enter some articles with various terms and make sure you enter some articles that contain the same term. When you view an article on the website you will see something like this:
So as you can see retrieving related articles based on their tags/terms is now extremely easy. Now it's simple to create new applications like tag clouds and related articles anywhere anytime.
This also opens up new possibilities in terms of using GX WebManager content on other websites. You can simple create an XML presentation that returns media items based on certain selection criteria. This allows you to create feeds similar to YouTube's API feed: http://gdata.youtube.com/feeds/api/standardfeeds/most_popular. Perfect for exchanging unformated content with 3rd party websites and apps. You can use an XML format similar to YouTube or Flickr or define your own XML format. It's all done in JSPs so you also benefit from caching and even personalization if you want.
Besides the getMediaItems several other functions have been added to offer more functions through the API:
In the PageManagementService
In the MediaRepositoryManagementService:
Please see the Javadoc for details.
Martin van Mierloo is Product Manager and has many years of experience with GX WebManager. Martin writes about the GX WebManager roadmap, new product features and WCMS related topics..
Read all Martins blog entries
Other blog entries: