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

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
patterns friendly url google analytics performance optimization CMS web design mysql social network content management white paper open text delivery server social media Active Directory google maps cloud computing code design tuckey cluster Database open text web solutions sales 2.0 web evolution iphone url css jquery, jquery plugin JSR-168 php online marketing reddot white paper social 2.0 tools open text management server sitecore meetup command line architecture open text liveserver java jquery VB portlets release management Solr higher education profile box web services content management whitepaper software design sitecore email campaign manager spatial content management los angeles CTA wcm webcomponent portal redundant database structure integration IT Investment facebook app, OS 3.0, three20 ui AS3 reddot cms higher education Business Users RFP boost deployment memcache licencing facebook template design jahia wcm open text CMS usability communicating Flash drush cloud VS2010 Navigation E-commerce oshyn Delivery Server asp data access content authoring javascript php5 Sitecore Active Directory cookie-free domain search suggest GIS SEO html industry challenges drools lead generation Visual Studio plugin new sites web3.0 Marketing Automation mashups mashup mashware keywords campaigns Dynamic Data target dynament cms whitepaper keyword selection LiveServer templating multilingual web development los angeles sitecore user group jahia cms modules reddot higher education content management systems Drupal CRM google reddot WCM Design Patterns ajax web2.0 concrete5 Sharepoint cms los angeles, content management los angeles, web development los angeles, website design los angeles, web design los angeles, sitecore meetup, sitecore user group location web marketing for dummies development fbml ASP.NET MVC SMM IIS postgis rdbs ipc LS geographical reddot cms Ubercart editing content Live Server EPiServer marketing VPP design missing images frontend optimization profile tab scalability google appEngine call to action lucene google search appliance Acquia sitecore ECM multisite enterprise Sitecore presentation layer Visual Basic dynament LDAP open-source icefaces inbound marketing mobile search engine cms white paper design patterns tuning Jahia Actionscript 3 twitter MVC sitecore oms web content management EPiServer Active Directory open text cms geo opentext sitecore online marketing suite, online marketing suite reddot whitepaper jsp Ubuntu Server open source Web development APC CMS Training management oms web marketing website design los angeles ASP.NET HubSpot GSA Velocity facebook developers Maven ajax push lead management configuration management foursquare linux thoughts liferay content authors print OO Development sitecore layout ubuntu consulting web design los angeles theming cms los angeles .net sitecore devices project management content mangement
2010 Copyright Oshyn. All rights reserved.