I'm testing and playing with Joomla 4 alpha. What I tried to do is to quick-edit / modify the module Latest Article (mod_articles_latest), adding a new function.
In joomla 3.x I usually adding a new function to a module by adding it to helper.php file like this :
class ModNameHelper
{
public static function myFunctionName($param1,$param2)
{ ...
Then I call it from the default.php like this:
ModNameHelper::myFunctionName($param1,$param2);
Now I tried to duplicate these steps with mod_articles_latest by adding myCustomFunction to ArticlesLatestHelper.php like this :
/**
* @package Joomla.Site
* @subpackage mod_articles_latest
*
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Module\ArticlesLatest\Site\Helper;
defined('_JEXEC') or die;
use Joomla\CMS\Access\Access;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Factory;
use Joomla\CMS\Router\Route;
use Joomla\Component\Content\Site\Model\ArticlesModel;
use Joomla\Registry\Registry;
use Joomla\Utilities\ArrayHelper;
\JLoader::register('ContentHelperRoute', JPATH_SITE . '/components/com_content/helpers/route.php');
/**
* Helper for mod_articles_latest
*
* @since 1.6
*/
abstract class ArticlesLatestHelper
{
/**
* Retrieve a list of article
*
* @param Registry $params The module parameters.
* @param ArticlesModel $model The model.
*
* @return mixed
*
* @since 1.6
*/
public static function getList(Registry $params, ArticlesModel $model)
{ // this is the built-in function ... }
public static function myCustomFunction($myparam) {
}
and then called the function in the default.php like this
ArticlesLatestHelper::myCustomFunction($myparam);
But it returned fatal error :
Error: Class 'ArticlesLatestHelper' not found: Class 'ArticlesLatestHelper' not found
Can anybody tell me, what am I doing wrong in here? Thanks!