Difference between revisions of "How to use custom variables"
Line 23: | Line 23: | ||
plan_type|free | plan_type|free | ||
</source> | </source> | ||
+ | |||
In the Basic plan enter this: | In the Basic plan enter this: | ||
Line 29: | Line 30: | ||
plan_type|basic | plan_type|basic | ||
</source> | </source> | ||
+ | |||
In the Premium plan enter this: | In the Premium plan enter this: | ||
Line 53: | Line 55: | ||
<?php endif;?> | <?php endif;?> | ||
</source> | </source> | ||
+ | |||
Listings that have the Free plan would output "This is a free listing.", listings that have the Basic Plan would output "This is a basic listing.", etc. | Listings that have the Free plan would output "This is a free listing.", listings that have the Basic Plan would output "This is a basic listing.", etc. | ||
Line 67: | Line 70: | ||
inquiry|enabled | inquiry|enabled | ||
</source> | </source> | ||
+ | |||
In the theme file of the listing detail page (/listings/detail.thtml) you can add this code: | In the theme file of the listing detail page (/listings/detail.thtml) you can add this code: | ||
Line 75: | Line 79: | ||
<?php endif;?> | <?php endif;?> | ||
</source> | </source> | ||
+ | |||
This code would display the inquiry form only in listings whose owners purchased the plan that contains the '''inquiry''' custom variable. | This code would display the inquiry form only in listings whose owners purchased the plan that contains the '''inquiry''' custom variable. |
Revision as of 20:47, 20 November 2013
Custom variables provide additional flexibility to your pricing plans. The variables are made available in the theme files so you can use them for customizations. For example, you can show/hide specific page elements based on the variables that are included in the plan.
To set custom variables, edit your pricing plans and in the Advanced tab add the variable name and variable value in this format:
To access the custom variables use this code:
<?php echo $Paid->getVar('var1',$listing);?>
Simple example of creating conditionals in the theme files based on custom variables
Let's say you created 3 plans: Free, Basic and Premium
For each of those plans you can set a variable with the same name, but different value, for example:
In the Free plan enter this:
plan_type|free
In the Basic plan enter this:
plan_type|basic
In the Premium plan enter this:
plan_type|premium
Then in the theme files (i.e. /listings/detail.thtml) you can create conditionals like this:
<?php if ($Paid->getVar('plan_type',$listing) == 'free'): ?> This is a free listing. <?php elseif ($Paid->getVar('plan_type',$listing) == 'basic'): ?> This is a basic listing. <?php elseif ($Paid->getVar('plan_type',$listing) == 'premium'): ?> This is a premium listing. <?php endif;?>
Listings that have the Free plan would output "This is a free listing.", listings that have the Basic Plan would output "This is a basic listing.", etc.
This way you can show/hide different parts of theme files based on the custom variable value.
Adding Inquiry Form to listings based on the custom variable
Let's say you want to show the inquiry form on listing detail pages, but only on listings that whose owners purchased the Premium plan.
In the Premium plan you can add a custom variable like this:
inquiry|enabled
In the theme file of the listing detail page (/listings/detail.thtml) you can add this code:
<?php if ($Paid->getVar('inquiry',$listing) == 'enabled'): ?> <?php echo $this->element('inquiry_widget');?> <?php endif;?>
This code would display the inquiry form only in listings whose owners purchased the plan that contains the inquiry custom variable.
To use this approach for the Inquery Form, you first need to disable the default inquiry functionality in JReviews Configuration, Listings tab. You need to set Enable Listing Inquiries to No.