Skip to content

phpGrid on Joomla

phpGrid can be easily integrated with Joomla. 

It requires the popular Sourcerer extension. The free version can be installed directly in the Joomla admin panel.

Steps:
  1. Install Sourcerer in Joomla
  2. phpGrid must be saved to Joomla folder <SITE NAME>/libraries
  3. Edit database settings in phpGrid/conf.php to the database you want to use for grid. In the same file, be sure set FRAMEWORK to JOOMLA all capital.
  4. Edit file  server/classes/cls_session.php
    • Set 'JPATH_BASE’ to the actual site name
      For example: 
      define('JPATH_BASE', '/var/www/mysite');

It's important to note that because we essentially embed PHP code in the content of Joomla article via the magic of Sourerer, the "use namespace" CANNOT be used such as

use phpGrid\C_DataGrid

This is because any namespace importing must be declared on the top of the page, which is not accessible in article editor. Instead, we must include the fully qualified namespace when initializing phpGrid:

$dg = new phpGrid\C_DataGrid("SELECT * FROM irt8i_modules", "id", "irt8i_modules");

Example of creating a grid in Joomla's article.  

{source}
<div id="mygrid">
<?php
require_once("/var/www/mysite/libraries/phpGrid/conf.php");

$dg = new phpGrid\C_DataGrid("SELECT * FROM irt8i_modules", "id", "irt8i_modules");
$dg->enable_autowidth(true)->enable_autoheight(true);
$dg->enable_search(true);
$dg->enable_edit('FORM');
$dg -> display();
?>
</div>
{/source}

Outcome:


Happy Joomla + Grid!


 

Feedback and Knowledge Base