SurfRay

Home Tech Blog Tech Talk Editing XSLT templates for Ontolica

Editing XSLT templates for Ontolica

E-mail Print PDF

Ontolica uses XSLT templates for appearance customization of its web parts. Hence, it is possible to change the way search dialogs and results are displayed. Creating and editing XSLT templates is easier when using a specialized XML editor.

Microsoft SharePoint Designer is a good choice for that purpose, because it provides close integration with SharePoint and supports XML formatting and XSLT transformations. It is also distributed as a free download from the Microsoft website. In this article we show an example of how SharePoint Designer can be used to create/edit XSLT templates to freely customize the appearance of the Ontolica Search Center.

We assume that you have already installed and enabled Ontolica functionalities in your MOSS environment. In that case you can proceed with opening the Ontolica Search Center site in SharePoint Designer. Click File / Open Site… and provide the URL of the Ontolica site.

01_open

02_open_2

If the site is opened successfully then all the content associated with the site will be listed in the Folder List of SharePoint Designer.

03_opened_1

Navigate to OntolicaStyles (Ontolica Styles) folder in the Folder List. This location contains all XSLT templates used by different Ontolica web parts. For example, Search Result folder contains templates that control the appearance of the search results provided by Ontolica.

04_file_list_1

If you want to modify existing templates or create your own templates, you can use the Copy/Paste feature in SharePoint Designer to create a copy of the existing template. In the first case, the new file can be used as a backup. In the second case, the content of the copied file can be used for inspiration and can be replaced with your own content. In the following example we copy the Default.xsl file and paste it in the same location.

05_copy

 

06_paste

The aforementioned operation creates a copy of the file, which can be renamed according to your needs. You can open the file in SharePoint Designer editor and start exploring the code.

07_new_template

Before you proceed to the next step, make sure that the new file was created in the same folder as the original file. This way the file will be immediately available on the appropriate Ontolica configuration page.

To enable the newly copied/created template go to Site Actions / Edit Page menu of your site.

08_edit

Then click on Configure this Search Result Web Part to open the configuration page.

09_config

The new template should be visible in the list of available search result templates, where you can select it and therefore use the template for displaying search results. Remember to uncheck the Cache compiled XSLT templates checkbox in order to make your code changes done in SharePoint Designer to be instantly applied upon saving the file in SharePoint Designer editor. (Please note that your new template might not have a preview available on the configuration page.)

10_config_2

After clicking the OK button you will be taken back to the Edit Page view where you need to use the Publish button to confirm and publish the performed changes.

11_publish

Now that the new template has been enabled, you can go back to the SharePoint Designer editor and make required changes in the code of the template.

Every time you will save the template file, the changes should be instantly visible in the Ontolica search results page.

 
Get Trial
Get Price Quote

Upgrading Ontolica 4.0 to Ontolica 2010

SurfRay’s commitment is to provide the best possible search solution for SharePoint. By continuing to refine our software and deliver improvements that delight and enable...

More:

How to index PDF files in SharePoint

Microsoft SharePoint does not index Adobe PDF files by default. Hence, additional steps are required to enable and perform indexing, to be able to search for the content ...
More: