How to customize the layout of custom fields in Theme files

From JReviews Documentation
Revision as of 23:13, 23 August 2010 by Jreviews (Talk | contribs)

Jump to: navigation, search

To simplify the initial setup of jReviews, there's a default output of custom fields both for listings and reviews. However, if you want to customize the output of the themes you can unpublish the fields from both list and detail views in the Fields Manager and place the fields where you want.

Custom field placement also allows to use fields in javascript code for Google Maps and other scripts you want to use.


Listing custom fields

The following code works in these files:

  • /listings/detail.thtml
  • /listings/listings_blogview.thtml
  • /listings/listings_tableview.thtml
  • /listings/listings_thumbview.thtml
  • /modules/listings.thtml


Outputting a certain custom field

Outputs the field label

<?php echo $CustomFields->label('jr_fieldname',$listing); ?>


Outputs the field value

<?php echo $CustomFields->field('jr_fieldname',$listing); ?>


Get field text without click2search or output re-format

You can also have a bit more control of the output by using additional parameters when you call the display method: $CustomFields->field($name, &$element, $click2search = true, $outputReformat = true)

The example below calls the brand field and turns off click2search and outputreformat advanced options:

<?php echo $CustomFields->field('jr_brand',$listing,false,false); ?>


Get text of selected option for select list with images

If you have a select field with images associated to options and want to get the field text for the selected option, use this code:

<?php echo $CustomFields->fieldText('jr_brand',$listing,false,false); ?>


Outputting a certain field group

Outputs a whole field group using the default output.

<?php  echo  $this->element('custom_fields',array('entry'=>$listing,'group_name'=>'Group  Name','page'=>'content','divWidth'=>'style="width:55%;"')); ?>

Just enter the correct Group Name below after the =>. You can use this to put different groups in different tabs when combined with a tabs plugin.


Review custom fields

You can place review custom fields in these files:

  • /reviews/reviews.thtml (only for user reviews)
  • /modules/reviews.thtml


Outputs the field label

<?php echo $CustomFields->label('jr_fieldname',$review); ?>


Outputs the field value

<?php echo $CustomFields->field('jr_fieldname',$review); ?>


In /listings/detail.thtml for the editor review custom fields you can use this code:


Outputs the field label

<?php echo $CustomFields->label('jr_fieldname',$editor_review); ?>


Outputs the field value

<?php echo $CustomFields->field('jr_fieldname',$editor_review); ?>


Custom Field conditionals

Create conditional output based on field's value

<?php if($CustomFields->field('jr_fieldname',$listing,false,false) != ''):?>
<!-- Add your code here-->
<?php endif;?>