Thursday, 27 November 2014

Extending displaying WCM search results in web content viewer portlet

Prerequisite :- Please refer to all my previous blogs on WCM search.

Overview :- Now we will further refine the search by providing users a option to search against Authoring template or site-area or content. After reading this blog you can use the meta data you want and make a custom search form. When user click on search button this time we will display content using portal theme in same page.

Search Metadata :- Below are the available points using which you can search against web content management.
Name – the name field of the content
Title – the title field of the object
Descr – the description field
Authors – the authors of the object, in the full distinguished name form
Keywords – the keywords of the object
Lastmodifieddate – the last modified date of the document.
AuthoringTemplate – the Title of the authoring template for the object, assuming content
Category – the Titles of the categories associated with the content
Modifier – the last modifier, in full distinguished name format
Owners – the owners of the document, in full distinguished name format
ExpirationDate – expiration date of the document,
EffectiveDate – effective date of the document

Example :- Now we have the attributes to search against WCM. Now how will you submit your required fields to WCM. For this we will use a form have with text fields in it and submit our attributes. Now we will map names of the key fields to search metadata.


The following parameters can be used in a search query in this format:
<input name="search_parameter" />
search_query
Used to search the content of any elements stored in a content item.
search_authoringtemplate
Used to search the authoring template, if available, that was used to create the content item.
search_authors
Used to search the name or names of the authors for the content item, if any are defined.
search_categories
Used to search the categories of the content item if any are defined.
search_description
Used to search the description of the content item.
search_effectivedate
Note: Search by date only works with the format MMM DD YYYY. For example, Sep 20 2006. To change the format, you will need to edit the SearchService.DateFormatString parameter in the SearchService.properties file.
Used to search the effective date of the content item.
search_expirationdate
Note: Search by date only works with the format MMM DD YYYY. For example, Sep 20 2006. To change the format, you will need to edit the SearchService.DateFormatString parameter in the SearchService.properties file.
Used to search the expiration date of the content item.
search_keywords
Used to search the keywords of the content item if any are defined.
search_lastmodifieddate
Note: Search by date only works with the format MMM DD YYYY. For example, Sep 20 2006. To change the format, you will need to edit the SearchService.DateFormatString parameter in the SearchService.properties file.
Used to search the last modified date of the content item.
search_modifier
Used to search the name of the last person to modify the content item.
search_name
Used to search the name of the content item.
search_owners
Used to search the name or names of the owners of the content item, if any are defined.
search_title
Used to search the title of the content item.

So as a simple example. Lets say I want to search for content that includes the term “IBM”, AND is tagged with a category that has a title of “IBM”.

Sample form :-
<form
action='<PathCmpnt type="servlet"/>/pathToLibrary/siteArea/content method="post">
<table>
<tr><td>
Search Query:
<input type="text" name="search_query"/><br>
Search Category:
<input type="text" name="search_categories"/><br>
</td></tr>
<tr><td align="right">
<input type="submit" value="Search"/>
</td></tr>
</table>
</form>

Opening search results in same page:-  To render the search results in same page we need to submit the form to itself. Edit the PT mentioned in previous blog to as given below{Alternate way is to set a page context by selecting receive context from current page in advanced options in edit mode}.



Now search for a text as given below


Now search results are displayed in same page as desired


Customizing table to look good :-  Modify the html code of search component the way you want


Modify Search-result-navigation to remove go to page number and decrease pagination to 3




Final output



No comments:

Post a Comment

Custom single threaded java server

 package com.diffengine.csv; import java.io.*; import java.net.*; import java.util.Date; public class Server { public static void main(Str...