Contact

Welcome to Breakout Developer!

Aims: Create a selection filter for the slider projection. Lets say we only want 'feature' items appearing when we select them. We could go and fetch the ids and create a filter that way but having a check-box on the editor page for the content type is far more user friendly.

To achieve this we are going to need to do a bit of work. First we need a part and a record that can be used to define the sql query for the content items.

This part will be used to enable the item to be included in the query.

public class ItemSliderPart : ContentPart<ItemSliderPartRecord>

public bool ShowItem {

get { return this.Record.ShowItem; }

set { this.Record.ShowItem = value; }

}

}

The Record is as simple:

public class ItemSliderPartRecord : ContentPartRecord {

public virtual bool ShowItem { get; set; }

}

The above part is attached to the content type which is being displayed in the Query. Time to create and define the filter for the query then...

Second part is a little more fiddly with dynamic forms but should be simple enough.

The two sections that we need to implement are:

IFilterProvider - Defines the query options and any forms that may belong to the options

IFormProvider - Define a dynamic form that the provider can find and display for the filter option(s)

Name and Descriptionare how the filter are visibly shown in the group lists. Filter how Describe.For is the section where the item falls into.

filter: ApplyFilter - develop the query by saying how the value is used from the part. When the setting is needed and how to therefore query the data. The filter is creating two options:

Enabled: Require part value to be true.

Not checked: equivalent to not having a filter on the query.

display: DisplayFilter - Displays a user hint and describes how the filter is acting when once enabled.

form: "SliderItemFilter" - the dynamic form that the user uses to set the filter. The form is described through the implementation of IFormProvider. The provider creates a dynamic form, where its name matches the above string.

Introduction

Use this guide to help you navigate some aspects of customizing the search in Orchard. Afterwards you will be able to index fields of a part in the example I will be using price and indexing a quick mock of products.

AdvancedSearchController - Overrides the default controller for Search as well as provides the views and shapes for the advanced search. Additionally it serves up results by the content type found in the custom settings rather than the default summary, providing a little more flexibility.

If the module is needed in pre 1.7 version this part will need a little change (SliderLayout.cs):

var options = new SliderSettings

{

Id = context.State.SliderId,

CssName = context.State.CssName,

Speed = context.State.Speed,

Delay = context.State.Delay,

Complete = context.State.Complete,

Keys = context.State.Keys,

Dots = context.State.Dots,

Fluid = context.State.Fluid

}

The above state is a dynamic object that will handled by Newtonsoft Json (Orchard v1.7 or current 1.x branch), which is clever enough to work out the types and allows me to write less code. Previous versions of Orchard use the default JSON provider and will fail at parsing string to number, and string to a nullable<bool> on the above lines but is easy enough to write a little more to check the conversion of string to type.

The shape part is built by SliderLayout.cs and described by the query part (while setting up the layout description) of the projection. Basically the shape display type can be set allowing for different alternates and content templates for the slider. Lets come back to this later.

4. Styling

Unslider describes what the CSS must have:

.banner { position: relative; overflow: auto; }

.banner li { list-style: none; }

.banner ul li { float: left; } should be wrapped as inline.

Replacing .banner for the css class name specified during the layout creation. For this module Im using LESS CSS files to help create and maintain the final CSS files (development and minified production).

The current navigation lacks the ability to hide individual menu items easily on the same menu group. A solution would be to create many menu sections and hide them on different menu widget layers. Instead, I have attempted to tackle this limitation by allowing each menu item to have its own rules keeping things down to the minimum amount of menus.