Updating PHPlugins from Backlight 1

Credit due to @Daniel for originally posting this; I’m moving it here from the old forum.

This is just a short summary on how to update phplugins from Backlight 1 to Backlight 2 (and now Backlight 3).

It’s a good idea to look at the new sample file (backlight/custom/phplugins/phplugins-pangolin-sample.php) to see all the available functions and how the file structure is.

  1. Phplugins are now class based. So all functions need to be defined within a class context. This is well seen in the example file.
class PHPlugins extends APHPlugins {
  // put your functions here 
}
  1. Function names changed and lost their arguments. You only need to remove the ttg_ prefix and whatever is between parentheses.

Before:

function ttg_pallet_top_title( $style, $path ) { 
  echo '
    // ......
  ';
  return false;
} // END /**/

After:

// Basic structure for a PHPlugins function
function pallet_top_title() { 
  echo '
    // ......
  ';
  return false;
} // END /**/
  1. If you call another function within the PHPlugins class, you need to use
$this->my_function()

instead of just

my_function()
  1. Backlight 1 $style and $path arguments are accessible as
$this->style

and

$this->path

Tip:

Please first make a copy of either /backlight/custom/phplugins/phplugins-pangolin-sample.php or /backlight/custom/phplugins/phplugins-okapi-sample.php and give it a good name: let’s call it /backlight/custom/phplugins/site-phplugins.php. Then select this file in your template editor as your site’s phplugins file. Add your custom functions from your Backlight 1 phplugins file and adjust them accordingly.

2 Likes

This is a very useful tip as PHPlugins always seemed a bit of a Cinderella to me and I tended not to review what was different in new releases compared to my working version. I’ll re-visit mine with this tip in mind