the main issue in my module is :
the developer said :
Our current module is built on the Joomla 3 structure but functions well with Joomla 5 in standard mode .At the moment, we do not support com_ajax .
now i converted it to joomla 5 structure by following the module tutorial .
so this is what i did :
1- i added these new files to convert the module to j5 structure :
public_html/modules/mod_mymodule/script.php
public_html/modules/mod_mymodule/services/provider.php
public_html/modules/mod_mymodule/src/Dispatcher/Dispatcher.php
public_html/media/mod_mymodule/joomla.asset.json
public_html/media/mod_mymodule/js/add-suffix.js
i added this function in the original helper file (original = from the developer) :
Code: Select all
public function loadvideosAjax()
added in this file :
public_html/modules/mod_mymodule/src/Helper/MymoduleHelper.php
2- now i have an error say:
the file helper.php not found .
i dont know why it call helper.php , i added the function in MymoduleHelper.php
how can i address the js code to MymoduleHelper.php ?
this is the provider.php code :
Code: Select all
<?php
\defined('_JEXEC') or die;
use Joomla\CMS\Extension\Service\Provider\Module as ModuleServiceProvider;
use Joomla\CMS\Extension\Service\Provider\ModuleDispatcherFactory as ModuleDispatcherFactoryServiceProvider;
use Joomla\CMS\Extension\Service\Provider\HelperFactory as HelperFactoryServiceProvider;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
return new class () implements ServiceProviderInterface {
public function register(Container $container): void
{
$container->registerServiceProvider(new ModuleDispatcherFactoryServiceProvider('\\PluginsWare\\Module\\Mymodule'));
$container->registerServiceProvider(new HelperFactoryServiceProvider('\\PluginsWare\\Module\\Mymodule\\Site\\Helper'));
$container->registerServiceProvider(new ModuleServiceProvider());
}
};
this is the dispatcher.php code :
Code: Select all
<?php
namespace PluginsWare\Module\Mymodule\Site\Dispatcher;
\defined('_JEXEC') or die;
use Joomla\CMS\Dispatcher\AbstractModuleDispatcher;
use Joomla\CMS\Helper\HelperFactoryAwareInterface;
use Joomla\CMS\Helper\HelperFactoryAwareTrait;
use Joomla\CMS\Language\Text;
use PluginsWare\Module\Mymodule\Site\MymoduleHelper;
class Dispatcher extends AbstractModuleDispatcher implements HelperFactoryAwareInterface
{
use HelperFactoryAwareTrait;
}
this is the js code :
Code: Select all
function loadmore_videos() {
let loadvideos = document.querySelector('.sof-videos-row');
Joomla.request({
url: 'index.php?option=com_ajax&module=yendifvideoshare_videos&method=loadvideos&format=json',
method: 'POST',
onSuccess(data) {
const response = JSON.parse(data);
if (response.success) {
loadvideos.innerHTML = response.data;
} else {
const messages = {"error": [response.message]};
Joomla.renderMessages(messages);
}
},
onError(xhr) {
Joomla.renderMessages(Joomla.ajaxErrorsMessages(xhr));
const response = JSON.parse(xhr.response);
Joomla.renderMessages({"error": [response.message]}, undefined, true);
}
});
}
when i click on this button :
Code: Select all
<div onClick="loadmore_videos()" class="sof-loadmore-button" >see more videos</div>
i get error :
the file helper.php not found .
any help ?