Difference between revisions of "JReviews:Add-on Development"

From JReviews Documentation
Jump to: navigation, search
m
m
Line 1: Line 1:
 
__TOC__
 
__TOC__
  
<span class="jrInfo">Add-on development requires a basic understanding of PHP and MySQL.</span>
+
<span class="jrInfo">Add-on development requires a basic understanding of PHP and MySQL and JReviews version 2.4.13.1 or higher.</span>
  
= What are add-ons and what can I do with them? =
+
= What is an Add-on? =
  
 
JReviews add-ons can extend the core functionality without the need to modify code in the JReviews core. Add-ons can have administration settings and management functionality, similar to the ones found in GeoMaps, PaidListings and the WidgetFactory. They can have their own front-end menus to create new pages on your site. They can intercept database query requests and modify or extend the results of queries and they can also modify any variable that is sent to a view before the view is rendered.
 
JReviews add-ons can extend the core functionality without the need to modify code in the JReviews core. Add-ons can have administration settings and management functionality, similar to the ones found in GeoMaps, PaidListings and the WidgetFactory. They can have their own front-end menus to create new pages on your site. They can intercept database query requests and modify or extend the results of queries and they can also modify any variable that is sent to a view before the view is rendered.
 +
 +
= Creating an Add-on =
 +
 +
Add-ons live in the /components/com_jreviews_addons folder and at a minimum must have an XML file and a JReviews plugin PHP file. The XML file lets JReviews identify the add-on. The JReviews plugin PHP file can run code on specific events to modify the front-end functionality. To get started we'll use a simple example that will append the category title to the listing title in detail pages.
 +
 +
== Creating the Add-on XML file ==
 +
 +
The XML filename should match the <name> tag inside the XML file and should also match the add-on's folder name in <span style="color:blue">/components/com_jreviews_addons</span>.
 +
 +
<source lang="xml">
 +
<?xml version="1.0" encoding="utf-8"?>
 +
<addon> 
 +
  <title>Title Modifier</title>
 +
  <name>titlemodifier</name>
 +
  <description><![CDATA[Title Modifier]]></description>
 +
  <author>ClickFWD LLC</author>
 +
  <url>http://www.reviewsforjoomla.com</url>
 +
  <created>02/17/2014</created>
 +
  <version>1.0.0.1</version>
 +
  <copyright>Copyright (C) 2010-2014 ClickFWD LLC</copyright>   
 +
  <license>http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL</license>
 +
</addon>
 +
</source>
 +
 +
Create the folder and file <span style="color: blue">/components/com_jreviews_addons/titlemodifier.xml</span>. Paste the code above and save. Then go to the JReviews Add-on Manager's Discover tab and you should find the new 'Title Modifier' add-on. Check the box for it and install it.
 +
 +
** IMAGE **
 +
 +
Now if you switch to the Add-on Manager's 'Manage' tab you'll find your new add-on there:
 +
 +
** IMAGE **
 +
 +
== Creating the Add-on plugin PHP file ==
 +
 +
The plugin php file is where all of the magic happens for add-ons that want to modify existing functionality. The plugin file can have any name you want, but we typically use the same add-on name for the plugin filename. Create the file <span style="color:blue">/components/com_jreviews_addons/titlemodifier/plugins/titlemodifier.php</span> with the code below:

Revision as of 14:08, 17 February 2014

Add-on development requires a basic understanding of PHP and MySQL and JReviews version 2.4.13.1 or higher.

What is an Add-on?

JReviews add-ons can extend the core functionality without the need to modify code in the JReviews core. Add-ons can have administration settings and management functionality, similar to the ones found in GeoMaps, PaidListings and the WidgetFactory. They can have their own front-end menus to create new pages on your site. They can intercept database query requests and modify or extend the results of queries and they can also modify any variable that is sent to a view before the view is rendered.

Creating an Add-on

Add-ons live in the /components/com_jreviews_addons folder and at a minimum must have an XML file and a JReviews plugin PHP file. The XML file lets JReviews identify the add-on. The JReviews plugin PHP file can run code on specific events to modify the front-end functionality. To get started we'll use a simple example that will append the category title to the listing title in detail pages.

Creating the Add-on XML file

The XML filename should match the <name> tag inside the XML file and should also match the add-on's folder name in /components/com_jreviews_addons.

<?xml version="1.0" encoding="utf-8"?>
<addon>   
   <title>Title Modifier</title>
   <name>titlemodifier</name>
   <description><![CDATA[Title Modifier]]></description>
   <author>ClickFWD LLC</author>
   <url>http://www.reviewsforjoomla.com</url>
   <created>02/17/2014</created>
   <version>1.0.0.1</version>
   <copyright>Copyright (C) 2010-2014 ClickFWD LLC</copyright>    
   <license>http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL</license> 
</addon>

Create the folder and file /components/com_jreviews_addons/titlemodifier.xml. Paste the code above and save. Then go to the JReviews Add-on Manager's Discover tab and you should find the new 'Title Modifier' add-on. Check the box for it and install it.

    • IMAGE **

Now if you switch to the Add-on Manager's 'Manage' tab you'll find your new add-on there:

    • IMAGE **

Creating the Add-on plugin PHP file

The plugin php file is where all of the magic happens for add-ons that want to modify existing functionality. The plugin file can have any name you want, but we typically use the same add-on name for the plugin filename. Create the file /components/com_jreviews_addons/titlemodifier/plugins/titlemodifier.php with the code below: