Tag Archives: Umbraco

Implementation of Search In Umbraco Using Examine

In this tutorial we will implement search in Umbraco, without using any plug-in. We will use examine and razor view in this tutorial. First let’s have a short intro to Umbraco and what is Examine.

Short intro to what is Umbraco?

Many Content Management System are used in the world today like (WordPress, Joomla, Prestashop Durapal etc.). One CMS that is not commonly well known is Umbraco.

Umbraco is an open source Microsoft .Net Content Management System (CMS) that runs some of the biggest site on the web. It has the flexibility to run from a small website like (small campaign or brochure sites) to full complex web application.

Umbraco has a very friendly CMS system but the best thing about Umbraco is that you can create any complex application using Asp.net (web forms or MVC).

Examine

Examine basically used lucene.net as its search engine. Examine using lucene.net provides very powerful and fast searching and it is also very simple to use.

We can perform quick search on very large data using lucene.net, Examine uses the lucene.net search/index engine and allows us to index and perform search easily.

This tutorial will show how to use examine to implement search.

Configuration of examine

For the configuration of examine we require these to config files.

/Config/ExamineIndex.config
/Config/ExamineSettings.config

ExamineIndex.config

Here we will create a new index set which contains the information of doctypes we want to index.

image-1

Place this indexset just below the other

SetName is the reference, or the alias if you like that we want to remember when were gonna call the index from our providers.

IndexAttributeFields defines all the default Umbraco fields that a node contains such as name, nodetype and more.

IndexUserFields is the alias of the custom fields you have added to your doctypes.

IncludeNodeTypes is the alias of the doctypes you want to search through.

Examine Settings.config

Here we want to do 2 things, adding index and search provider. This index our data and give us the search option.

  • Index Providerimage-2

Paste it before

</providers>

</ExamineIndexProviders>

  • Search Providerimage-3

Paste it before

</providers>

</ExamineSearchProviders>

Now go to Umbraco admin panel and in setting go to document types and create a new document type search. Now create a new tab “content” and add the following two generic properties using content tab.

image-4

Now do to the home document type or the main document type of your web and go to the structure tab and click the check box with search document type in “Allowed Child type nodes”.

Now we will create a new PartialViewMacrofiles (Search.cshtml) and paste the following code.

image-5-1

image-5-2

image-5-3

Using this macro partials we will create a macro, go to developer section in macro create a new macro Search

image-6

Now we create a search template. Go to setting in Umbraco Admin panel and in Templates under master layout create a new template, according to your design add the following two lines.

<h1>@CurrentPage.PageTittle</h1>

<p>@CurrentPage.BodyText</p>

Now go to the content section, create a new page as name as search and in the boddytext call the macro.

image-7

Now the last step is to create a search box on your page, add the following code in master lay out

image-8

I have used a image as a click search button, you can create it your own way. Now to perform search on inner pages add the following java script code.

image-9

And finally here are the search results.

image-10

Blog-CTA

How to Create Local Package in Umbraco 7

In virtually all open source projects that are particularly within the CMS i.e. content management system space, add-on modules are available that both the developers and editors can install to improve the system functionality. You’ve probably heard them being called as apps, modules, add-ons, plugins, and extensions.

Following is the guide to creating a local package in Umbraco.

1

1. Right-clicking the Packages node in the Developer section, as shown in Figure.
2. Name your new package xxxx by filling in the name field in the resulting popup.
3. Fill in all the fields in the Package Properties tab, as shown in Figure.
Package URL: The URL of the site where this package is described/documented.

Package Version: That is, 1.0 or 0.1 and so on.

Package file: This field remains empty until you publish the package.

Author Name: Full name of the author of the project. Contributors can be added to the project details when uploading to the community site, but only one author should be listed as part of the package details.

Author URL: Your blog or corporate site URL.

License Name: Researching the license model for the package is up to you. The default is MIT, just like the Umbraco core.

License URL: This would be the URL for the details of your license.

Read me: This field is your opportunity to educate the installer of what the package does and to include any special instructions.

2

4. Click the Package Contents tab and select the applicable elements to include.

3

 

5. .xslt and .ascx files for your macros will be added automaticly.Before publishing the package, all media objects, partial views, plug-in will be added manually in package file tab.

4

6. In addition to using the built-in tools for creating packages, you can extend the functionality by using the Package Actions tab. Package Actions are a means for you as a developer to execute common tasks during and after the installation process of a package. The actions are configured as instructions using XML. Examples of usage for these  actions include adding an <umbraco:macro /> tag to an existing template, allowing a document type as a child element of another, or moving nodes in the content tree. For example,

ACTION ALIAS: add Application
Description: Creates a new application and adds it to the database.
Sample Code: <Action runat=”install”
[undo=”false”]
alias=”addApplication” appName=”Application Name” appAlias=”myApplication” appIcon=”application.gif”/>

7- Once published you may download it from created packages.

5