Connecting to the database
So now the next file we need to create is helper.php
which contains our database connection and gets the data ready to display in the view. You should create this file in your mod_latestextensions
folder.
<?php defined('_JEXEC') or die; abstract class mod_latestextensionsHelper { public static function getList(&$params) { $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select('name, extension_id, type'); $query->from('#__extensions'); $query->order('extension_id DESC'); $db->setQuery($query, 0, $params->get('count', 5)); try { $results = $db->loadObjectList(); } catch (RuntimeException $e) { JError::raiseError(500, $e->getMessage()); return false; } foreach ($results as $k => $result) { $results[$k] = ...
Get Learning Joomla! 3 Extension Development - Third Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.