Wednesday, 28 January 2015

Calling model functions from another classes or views files in Joomla 3+

In Joomla 3+ version, to initialise any model and to call them from another model or helper or view class/files, please follow instruction;

For example, you have a sample model class (as shown below) which exists on
// No direct access to this file
defined('_JEXEC') or die('Restricted access');

// import the Joomla modellist library

 * Gallery Model
class MycomponentModelGallery extends JModelList
  * Method to fetch all list of published galleries
  * @return      string  An SQL query
 protected function getGalleryList()
  return $items;

Now, please use the below format initialising the gallery model and call the functions:
// Use JPATH_ADMINISTRATOR instead of JPATH_SITE to call administrator model classes;
// Include the file path;
JModelLegacy::addIncludePath(JPATH_SITE . '/components/com_mycomponent/models', 'MycomponentModel'); 
// Initialising the included class;
$gallery_model = JModelLegacy::getInstance('Gallery', 'MycomponentModel');
$galleries = $gallery_model->getGalleryList();

Friday, 2 January 2015

Options to run multi-versions PHP within on WHM Cpanel

If you are looking for solution to run multi-version of PHP by domain in WHM Cpanel, I have found people using tools called ntPHPSelector.

WHM Cpanel doesn't have such native feature, however, I have found their team were keen to build an extension for it in future. Hopefully, it will be available soon, fingures cross!! find more here..

Currently, there are few WHM providers which does support Multiple PHP Versions as below:
  • Virtualmin since 3.99 can do that
  • PLesk since 11.5 can do that
  • Direct Admin can do that
  • cPanel cannot do that unless you move to CloudLinux paying an additional license

Now, let jump to the wayout for now;

1. First check whether the suPHP Handler is enabled or not by going to WHM > Configure PHP and suEXEC
PHP 5 Handler => suphp

If not active, run the below command
/usr/local/cpanel/bin/rebuild_phpconf 5 none suphp 1

2. Run the following commond once you logged in as root into the server (Via SSH or you can use puTTY), which may take few mintues so wait until instillation completes.
cd /usr/local/src
wget -N
sh install

3. Go to the domain Cpanel and find the ntPHPSelector under the Software and Services to run the different version of PHP.

If you find anything, please keep on post...