Difference between revisions of "Using Custom Params, Custom Where and Custom Order settings"

From JReviews Documentation
Jump to: navigation, search
Line 1: Line 1:
Custom WHERE and Custom ORDER BY parameters are available in the  [[Listings Module]] and in the '''Custom List''' JReviews menu item.
+
Custom WHERE and Custom ORDER BY parameters are available in the  [[Listings Module]] and in the '''Custom List''' JReviews menu item. You can use them to filter listings based on certain values and order listings based on certain fields.
  
You can use them to filter listings based on certain values and order listings based on certain fields.
 
  
For example, to get all listings that have Cannon value for jr_brand custom field, we can use this in Custom WHERE parameter:
+
For every listing  custom field you created in the [[Fields Manager]] you can use <span  style="color: blue">Field.jr_fieldname</span> format.
<pre>Field.jr_brand LIKE '%canon%'</pre>
+
  
  
If we want to order those listings by highest price, we can enter this in the Custom ORDER BY parameter:
 
<pre>Field.jr_price DESC</pre>
 
  
 +
__TOC__
  
Field.jr_brand  and Field.jr_price are examples of the columns in the database that can  be used for Custom WHERE and Custom ORDER BY.
+
== CUSTOM WHERE Examples ==
For every listing  custom field you created in the [[Fields Manager]] you can use <span  style="color: blue">Field.jr_fieldname</span> format.
+
  
 +
Filter results to listings that have Canon value for the jr_brand custom field. For single select lists and radio button fields:
  
When checking the value of a text custom field, use this:
+
<pre>Field.jr_brand = '*canon*'</pre>
<pre>Field.jr_model = 'xyz'</pre>
+
<pre>Field.jr_city = '*new-york*'</pre>
  
  
When checking the value of a single select or radiobuttons custom field, use this (option value inside asterisks):
 
<pre>Field.jr_city = '*new-york*'</pre>
 
  
 +
For multiple select and checkbox fields:
  
When checking the value of a multiple select or checkboxes custom field, use LIKE with option value inside percentages:
+
<pre>Field.jr_brand LIKE '%*canon*%'</pre>
<pre>Field.jr_genre LIKE '%comedy%'</pre>
+
<pre>Field.jr_city LIKE '%*new-york*%'</pre>
  
  
To check if a decimal or integer field is higher than certain number, we can use this:
+
 
 +
If you want to filter the results to include more than one brand (multiple select, checkboxes)
 +
 
 +
<pre>(Field.jr_brand LIKE '%*canon*%' AND Field.jr_brand LIKE '%*sony*%')</pre>
 +
 
 +
 
 +
To filter results based on the value of a text custom field:
 +
<pre>Field.jr_model = 'xyz'</pre>
 +
 
 +
 
 +
To filter results based on the value of a numeric field:
 
<pre>Field.jr_price > 999</pre>
 
<pre>Field.jr_price > 999</pre>
  
 +
<pre>Field.jr_price BETWEEN 100 AND 1000</pre>
  
We can also check if the field is not empty:
+
 
 +
To filter results to listings that have a value filled in for a specific field:
 
<pre>Field.jr_brand != ''</pre>
 
<pre>Field.jr_brand != ''</pre>
 +
 +
 +
Find all events happening today or in the future using a date field
 +
 +
<pre>Field._eventdate >= DATE(NOW())</pre>
 +
 +
 +
== CUSTOM ORDER BY Examples ==
 +
 +
Order listings by highest price
 +
<pre>Field.jr_price DESC</pre>
  
  
  
 +
== Other database table columns you can use ==
  
'''Other available columns are:'''
+
The CUSTOM WHERE and ORDER BY use is not limited to custom fields.  You can also use it with many other standard table columns.
  
 
{| class="wikitable" cellpadding="0" cellspacing="0"
 
{| class="wikitable" cellpadding="0" cellspacing="0"

Revision as of 12:23, 16 February 2012

Custom WHERE and Custom ORDER BY parameters are available in the Listings Module and in the Custom List JReviews menu item. You can use them to filter listings based on certain values and order listings based on certain fields.


For every listing custom field you created in the Fields Manager you can use Field.jr_fieldname format.


CUSTOM WHERE Examples

Filter results to listings that have Canon value for the jr_brand custom field. For single select lists and radio button fields:

Field.jr_brand = '*canon*'
Field.jr_city = '*new-york*'


For multiple select and checkbox fields:

Field.jr_brand LIKE '%*canon*%'
Field.jr_city LIKE '%*new-york*%'


If you want to filter the results to include more than one brand (multiple select, checkboxes)

(Field.jr_brand LIKE '%*canon*%' AND Field.jr_brand LIKE '%*sony*%')


To filter results based on the value of a text custom field:

Field.jr_model = 'xyz'


To filter results based on the value of a numeric field:

Field.jr_price > 999
Field.jr_price BETWEEN 100 AND 1000


To filter results to listings that have a value filled in for a specific field:

Field.jr_brand != ''


Find all events happening today or in the future using a date field

Field._eventdate >= DATE(NOW())


CUSTOM ORDER BY Examples

Order listings by highest price

Field.jr_price DESC


Other database table columns you can use

The CUSTOM WHERE and ORDER BY use is not limited to custom fields. You can also use it with many other standard table columns.

Listing.title
Listing title
Listing.created
Listing submission date
Listing.modified
Listing update date
Listing.created_by
User ID
Listing.hits
Number of views
Frontpage.content_id
Joomla frontpaged listing (value > 0)
Field.featured
JReviews featured listing
Totals.user_rating
Average user rating
Totals.user_rating_count
Number of user ratings
Totals.editor_rating
Average editor rating
Totals.editor_rating_count
Number of editor ratings