Sign in

E-mail *, (xx@domain.com)
Password *

Register | Forgot password

Blogs

Recent blogs

RSS - Blogs
March 9, 2010
State of OSGi in the Java world
March 4, 2010
Reach more people with Google Translate
March 3, 2010
Get My Advice
February 26, 2010
What? Where!?!
February 11, 2010
Split it!

All Blogs...


New in WebManager 9.5 part 1: Content API additions

July 10, 2008

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.

getMediaItems()

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.

Content syndication

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.  

Other additions

Besides the getMediaItems several other functions have been added to offer more functions through the API:

In the PageManagementService

  • copyBlock(Page block, Page targetParentBlock)  and copyBlock(PageVersion blockVersion, Page targetParentBlock)
  • copyPageModel(PageModel pageModel)

In the MediaRepositoryManagementService:

  • createMediaTerm(Website website, java.lang.String termName)
  • getMediaItemFilterInstance()
  • getMediaItemSortOptionsInstance()

Please see the Javadoc for details.


About the Author

Return to all blogs


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:

March 9, 2010
State of OSGi in the Java world
March 4, 2010
Reach more people with Google Translate
July 20, 2009
How to benefit from the improved inline mode
May 29, 2009
Watch content!
May 12, 2009
Traffic and Conversion
April 17, 2009
The new Community Forum in 980
April 2, 2009
10 Years Cluetrain Manifesto
March 18, 2009
The CMS Vendor Meme
March 3, 2009
jQuery and GX WebManager
December 24, 2008
The year has almost ended...


Share:

del.icio.us
digg
Technorati
Slashdot
Reddit
YahooMyWeb
NewsVine
ekudos
© 2010 GX creative online development B.V.

Disclaimer

This website (GXdeveloperweb.com) may discuss or contain opinions, (sample) coding, software or other information that does not include GX official interfaces, instructions or guidelines and therefore is not supported by GX. Changes made based on this information are not supported.  GX will not be held liable for any damages caused by using or misusing the information, software, instructions, code or methods suggested on this website, and anyone using these methods does so at his/her own risk. GX offers no guarantees and assumes no responsibility or liability of any type with respect to the content of this website, including any liability resulting from incompatibility between the content of this website and the materials and services offered by GX. By using this website you will not hold, or seek to hold, GX responsible or liable with respect to the content of this website.