BLOG: Web Content Management

Welcome to Oshyn’s Web Content Management Blog where our experts discuss the latest developments and best practices in the Content Management industry with a focus on several leading platforms: Drupal, EPiServer, Jahia, Open Text and Sitecore.

Web 2.0 and Jahia: Using jQuery in Jahia

David Yanez... - Monday, January 18, 2010

Want to learn how to implement a jQuery plugin as a module in Jahia? First, we’ll add the same module twice in a page but passing different parameters to each module to change the appearance of both. Then we’ll implement AJAX in one module. Let’s imagine we are building a site in Jahia to sell products. The common things we find in a product page are product images, product descriptions, advertisements, etc.  For our product page we are adding a rating module that will allow us to show our score of the product, scores from another source (e.g. Other Web Site or Magazine) and let users rate the product and show their score too.We built a jQuery plugin that will allow us to display rating results. Plus letting the website visitor to rate the product in a simple way.In the image below we see how the plugin can show information, and how it lets the user rate the product using the slider. It is simple to show the rating module like in the second example.

To make the plugin work you need the following:

Include jQuery, uirateit plugin js and its css file.

<script type="text/javascript" src="jquery.js"></script>

<script type="text/javascript" src="uirateit.js"></script>

<link rel="stylesheet" type="text/css" href="uirateit.css" />

 

Then build the html with the next structure.

<div class="ratemodule" style="width:300px; height:133px; ">

<ul class="score">

<li class="bigscore">

<span>MySite.com Score</span>

<span>8.5</span>

<span>Awesome</span>

</li>

<li class="smallscore">

<span>8</span>

<span>Critic Score</span>

<span>32 review</span>

</li>

<li class="smallscore">

<span>8.5</span>

<span>User Score</span>

<span>32 review</span>

</li>

<li class="yourscore">

<span>NA</span>

<span>User Score</span>

<span>please slide to rate</span>

</li>
</
ul>

</
div>

and finally

<script type="text/javascript">

$(document).ready(function({barwidth: 191}){

$('. ratemodule ').uirateit();

});

</script>

Now we’ll implement the same plugin as a module in Jahia, so Content Editors can add the module to product pages customizing the view with different parameters.

In your definitions.cnd file add the next lines:

<ajax = 'oshyn.com/jahia/ajax/nt/1.0'>

[name_of_templates:rateModule] > jnt:container

    smallText siteMessage

    smallText siteRate

    smallText firstHeadline

    smallText firstMessage

    smallText firstRate

    smallText secondHeadline

    smallText secondMessage

    smallText secondRate

    smallText userHeadline

    smallText userMessage

    smallText moduleWidth

    smallText webSiteName

    smallText nameClass

     

[name_of_templates:moduleBox] > jnt:box

      containerList rateModuleList (ajax:rateModule)

     

[name_of_templates:home] > jnt:page

      containerList columnBox (jnt:box[availableTypes="jnt:IframeBox,ajax:moduleBox"])

[name_of_templates:rateModule] > jnt:container will[km1]  be our new module that inherits from container. We declare all the fields that the editor would be able to modify in the template.

After that we add the module container to our template

<template:boxList name="columnBox" id="columnBox" actionMenuNamePostFix="boxes" actionMenuNameLabelKey="boxes">

<template:container id="moduleBox" actionMenuNamePostFix="box" actionMenuNameLabelKey="box.update" cache="false" >
<template:box displayTitle="true" id="columnBox" onError="${jahia.requestInfo.normalMode ? 'hide' : 'default'}"/>
</template:container>
</template:boxList>

Finally we must create a display for our module following the Jahia naming convention.

Create a file under common/box/display/moduleBoxDisplay.jsp with next code.

<template:containerList name="rateModuleList" id="rates" actionMenuNamePostFix="rates" actionMenuNameLabelKey="rates">

<template:container id="rateModule" cache="off" actionMenuNamePostFix="rate" actionMenuNameLabelKey="rate.update">

<div class='<template:field name="nameClass"/>' style="width:300px; height:133px; position:relative; font-family:Arial, Helvetica, sans-serif;margin-bottom:20px;">

<ul class="score">

<li class="bigscore">

<span><template:field name="webSiteName"/></span>

<span><template:field name="siteRate"/></span>

<span><template:field name="siteMessage"/></span>

</li>

<li class="smallscore">

<span><template:field name="firstRate"/></span>

<span><template:field name="firstHeadline"/></span>

<span><template:field name="firstMessage"/></span>

</li>

<li class="smallscore">

<span><template:field name="secondRate"/></span>

<span><template:field name="secondHeadline"/></span>

<span><template:field name="secondMessage"/></span>

</li>

<li class="yourscore">

<span>NA</span>

<span><template:field name="userHeadline"/></span>

<span><template:field name="userMessage"/></span>

</li>

</ul>

</div>


<script type="text/javascript">

 $(document).ready(function(){

$('.').uirateit({

barwidth: <template:field name="moduleWidth"/>

}, function(){

});

});

</script>

</template:container>

</template:containerList>

           

As soon as you deploy the templates on Jahia, you will be able to add the new module.


and have something like this on your site:

ajax rotator
Recent Posts

RSS feeds
Tag cloud
Velocity content mangement jahia cms Active Directory cms los angeles Jahia ajax open text management server Navigation EPiServer Active Directory ipc web services open text web solutions Sharepoint open source sitecore oms content authors LDAP open text cms ASP.NET data access OO Development portlets SEO dynament LS Marketing Automation LiveServer opentext portal tuning content management los angeles EPiServer rdbs jsp jquery, jquery plugin sitecore devices patterns sales 2.0 Delivery Server twitter CTA social media javascript CMS usability jahia wcm plugin MVC fbml lucene web development los angeles sitecore layout oms google search appliance presentation layer new sites IT Investment wcm lead generation linux web content management architecture sitecore online marketing suite, online marketing suite open-source development code design html icefaces .net IIS drools JSR-168 performance cms los angeles, content management los angeles, web development los angeles, website design los angeles, web design los angeles, sitecore meetup, sitecore user group software design mobile print google analytics content management systems HubSpot community applications online marketing editing content ajax push tuckey social 2.0 tools reddot inbound marketing lead management Business Users licencing java release management industry challenges open text liveserver Sitecore enterprise liferay call to action php5 redundant database structure friendly url Drupal content authoring SMM oshyn ASP.NET MVC configuration management GSA GIS web2.0 reddot higher education marketing scalability Live Server search engine cms white paper open text design patterns url profile tab asp Solr CMS Training deployment search suggest web design los angeles facebook developers consulting mashups mashup mashware social network Web development design web evolution facebook app, OS 3.0, three20 jquery content management whitepaper template design Visual Studio google appEngine VPP web marketing google maps CMS reddot cms website design los angeles Visual Basic open text delivery server integration sitecore meetup google cloud higher education web design reddot whitepaper iphone reddot white paper keyword selection Flash Dynamic Data cloud computing keywords sitecore user group reddot cms higher education missing images VB profile box target dynament Sitecore Active Directory ui css Maven facebook webcomponent project management CRM cms whitepaper web marketing for dummies WCM Design Patterns content management white paper modules web3.0
2010 Copyright Oshyn. All rights reserved.