Search Documentation

Create pre-filtered links

Create link that will automatically apply filter to list of the articles.

Link for order

If you want to create link outside of Cobalt to pre-ordered list of articles use this URL.

http://www.com/index.php?option=com_cobalt&
	view=records&
	section_id=1&
	filter_order=r.title&
	filter_order_Dir=asc

Basic rule is that you should take URL of the list of articles you want including all parameters like section_id, Itemid or cat_id or others and add 2 new parameters.

Parameter Req. Description
filter_order Yes How to order. See below.
filter_order_Dir Yes What is order direction. Can be asc or desc

List of possible ordering types

  • r.ctime - Time of creation
  • r.mtime - modification time
  • r.extime - time of expiration
  • r.title - Article title
  • name - Name of the author
  • username - User name od the author
  • r.hits - Article views
  • r.comments - Number of comments
  • r.favorite_num - Number of bookmarks
  • r.votes_result - Rating

If your URL is SEF like http://domain.com/list then you can use ?

http://domain.com/list?filter_order=r.title&filter_order_Dir=asc

Link for filters

What if you what to create link in menu (or anywhere else), that can automatically set search filters you want for articles list? For example: Events for the next 14 days with location 20 miles within the London. You can easily do it with new Cobalt filter interface.

1. Create URL

After dramatic recoding all filtering mechanism, we ended up with filter interface to which you can communicate through special URL.

http://www.com/index.php?option=com_cobalt&task=records.filter&...

Here are all parameters that you can add to this URL.

Parameter Req. Description
section_id Yes Set section ID
Itemid Yes Menu Itemid. Please set Itemid of menu that you set in section itemid parameter
cat_id No Category ID if you want to filter in particular category only
filter_name Yes Array of the name of the filters. Explained later.
filter_val Yes Array of the values of the filters. Explained later.

After user click URL, filters will be set and user will be redirected to standard articles list URL. That is why we need section ID, Itemid and category ID. To land user to correct page. So please do not forget to set those parameters correctly.

2. Reset and Set Filters

If you want to reset all filters before you set new one, add to URL &clean=1.

http://www.com/index.php?option=com_cobalt&task=records.filter&clean=1&...

Otherwise filters will be added to curently applied filters.

3. Set Filters

filter_val and filter_name are arrays that set filters. You can add as many of them as you want. Here is the example.

&filter_name[0]=filter_tag&filter_val[0]=2

This is to show all articles with tag ID 2.

Standard filters

This table show you list of available standard filter_name and their filter_val.

Filter name Filter value Description
filter_tpl default Name of the article list template. If you want to use settings of the template you have to include filter configuration key. Somethign like default.b604f5fb1ca89b8be2706881a530680f. how you can get this key? Just look temmplate select source code in section edit page.
filter_cat 2 ID of the category
filter_user 42 ID of the user
filter_tag 2 ID of the tag
filter_type 1 ID of the content type
filter_search what is life Search string

Here is an example. It should be one line. I have formatted it just to make it more readable.

http://www.com/index.php
	?option=com_cobalt
	&task=records.filter
	&section_id=2
	&Itemid=126
	&filter_name[0]=filter_type
	&filter_val[0]=2
	&filter_name[1]=filter_user
	&filter_val[1]=42

This example will show all records of User Super Admin (ID 42) and content type ID 2.

Fields filters

First you have to form filter name. It contains of prefix filter_ and field key. So filter name may looks like this

&filter_name[0]=filter_k2hgsd5FdK79H6Gfdt6hxnsgF55fd

Then, you have to set filter value. And it may be very different for every field but basically only 2 types. Single value may looks like this

&filter_val[0]=value%201

Values have to be url encoded. You can see %20 means whitespace.

Or values may be an array

&filter_val[0][]=value%201&filter_val[0][]=value%202

In this case it will look for records that contain Value 1 OR Value 2

Sometimes it is important to identify array keys like for example for geo field.

&filter_val[0][lat]=41.25458745&filter_val[0][lng]=21.2654789

or date range

filter_val[0][range]=2014-09-01,2014-09-30

But that is very exclusive. Only Geo and DateTime fields. For data time first set is a data from and second date to

If you use boolean field then filter value is true OR false

&filter_val[0]=true

Sometimes you need to reset all filters by URL or single filter.

Reset all filters

index.php?option=com_cobalt
     &task=records.cleanall
     &section_id=2 
     &Itemid=123

Reset individual filter

index.php?option=com_cobalt
     &task=records.clean
     &clean[filter_k58596481bc7070e4adecd4f2e29569de]=1
     &section_id=2 
     &Itemid=123

There are few parameters to insert to clean variable

Filter Type Description
filter_search Reset text search
filter_type Reset content type filter
filter_tag Reset tags filter
filter_user Reset user filter
filter_alpha Reset alpha index filter
filter_cat Reset category filter
filter_[key] This is to clean field filter. You have to change [key] to field key like it is in example above.

You may reset few filters at once

index.php?option=com_cobalt
     &task=records.clean
     &clean[filter_k58596481bc7070e4adecd4f2e29569de]=1
     &clean[filter_type]=1
     &clean[filter_alpha]=1
     &section_id=2 
     &Itemid=123

Q: What is a field key?

Field Key now is the part of multi type support in templates. Field key is and MD5 of field type and label.

$field_key = 'k'.md5($field->label.'-'.$field->field_type); 

Lets, say field label is Year and field type id digits. Then

$field_key = 'k'.md5('Year-digits');

You can find keys in the DB column key in jos_js_res_fields table.

Field key

Or in the key column in fields manager (3).

Field key