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