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.

Jahia Search in the Enterprise

Jahia Search in the Enterprise

Juan Pablo Albuja... - Thursday, January 14, 2010

Jahia has an embedded search engine that can be used by a Tag Library. This library offers components to build forms, field elements, components to display search results, and components to implement the pagination. I want to share a way of how to use the Jahia Search Tag Library to do full text searches.


Configuring Search Results Page Template

I am assuming that you have some experience with template development. If not, you can find a quick review of template development here. When you create a template set, you need to configure the file templates.xml to declare the templates that are going to be part of the template, but also you can use this file to configure which page is going to handle search results. You need to add the following configuration to the file templates.xml.


<common-pages>
<search-results>SearchResult.jsp</search-results>
</common-pages>


SearchResults.jsp is the page that is going to display the search results executed by the Jahia Search Taglib.


Search Form

To build search forms, first you need to include the Jahia Search Taglib in the .jsp file that is going to contain the form


<%@ taglib uri="http://www.jahia.org/tags/search" prefix="s" %>


Then you need to use the tags and to build the form. Following is an example form:


<s:form name="fulltextsearch">
<table>
<tr>
<td class="title" style="width: 150px;">Search</td>
<td style="width: 350px;"><s:term class="text1"/></td>
<td><input type="submit" value="search" class="button"/></td>
</tr>
</table>
</s:form>


Search Results Page

The search results page is the page configured in the file template.xml to display the results. This page is called every time that a submit is performed in the s:form. You need to use the libraries:

<%@ taglib uri="http://www.jahia.org/tags/search" prefix="s" %>
<%@ taglib uri="http://jsptags.com/tags/navigation/pager" prefix="pg" %>


And the tags <s:results>, <pg:pager>, <s:resultIterator>,  <pg:item> to display the results.

The tag <s:results> is in charge to execute the search  and expose the results to be displayed, and <s:resultIterator> is in charge to iterate over the results.  The tag <s:results>  has the important method getCount(), to obtain the number of results, and can be accessed by the EL (Expression Language) ${count}.

The tag <pg:pager> is in charge of implement the pagination of large data sets and <pg:item> represents each page returned by the search.


Following is an example of how to use the above elements in action:

<s:results>
<table>
<pg:pager maxPageItems="10" url="${jahia.page.url}" export="currentPageNumber=pageNumber">
<s:resultIterator>
<pg:item>
<tr>
<td><a href="${hit.link}">${fn:escapeXml(hit.title)}</a></td>
<td>${hit.summary}</td>
</tr>
</pg:item>
</s:resultIterator>
</pg:pager>
</table>
</s:results>


Notice that the element <pg:pager> is used to define the number of results displayed per page. The <s:results> tag returns a java.util.List<org.jahia.engines.search.Hit> List, so for that reason you can use the EL ${hit.link}, ${hit.title} and ${hit.summary}.

Also you can include more pagination elements to handle the navigation. You can use the tags <pg:prev> and <pg:next> inside the tag <pg:index> like the following example:


<pg:index export="itemCount">
<pg:prev ifnull="true">
<c:if test="${not empty pageUrl}">
<a href="${pageUrl}">previous</a>
</c:if>
<c:if test="${empty pageUrl}">
previous
</c:if>
</pg:prev>        |
<pg:next ifnull="true">
<c:if test="${not empty pageUrl}">
<a> <a href="${pageUrl}">next</a></c:if>
<c:if test="${empty pageUrl}">
next
</c:if>
</pg:next>
</pg:index>


The following screenshot shows a search result page with pagination. Each page has the size of one, and notice that at the bottom of the page are the next and previous arrows to navigate through pages.


ajax rotator
Recent Posts

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