Lets say my component is called dumbo. It contains all kind of MVC stuff and works well. Now i have a second component that is called jumbo. I need both components to share some models, controllers and views (and other stuff) from a central library.
Of course this is helpful regarding that question:
https://docs.joomla.org/Using_own_library_in_your_extensions/en
But it seams i have done something wrong.
I have setup a namespace loader:
JLoader::registerNamespace('Mylib', JPATH_LIBRARIES . '/mylib');
Here comes an example model and view from the central library that dumbo and jumbo should share and use:
Directory the model is in:
.\libraries\mylib\listings\model.php
The model itself:
defined('_JEXEC') or die;
use Joomla\CMS\MVC\Model\ListModel;
class MylibListingsModel extends ListModel
{
public function __construct($config = array())
{
echo "lib model";
parent::__construct($config);
}
...
}
Directory the view is in:
.\libraries\mylib\listings\view.php
The view itself:
defined('_JEXEC') or die;
use Joomla\CMS\Toolbar\Toolbar;
use Joomla\CMS\Toolbar\ToolbarHelper;
class MylibListingsView extends JViewLegacy
{
protected $items;
protected $pagination;
protected $state;
public function display($tpl = null)
{
echo "lib view";
parent::display($tpl);
}
...
}
When calling the listings view from the dumbo component like this:
127.0.0.1/dumbo/administrator/index.php?option=com_dumbo&view=listings
The library structures are not found (View not found [Name, Typ, Präfix]: listings, html, dumboView)
I also added the JLoader::registerPrefix('Mylib', dirname(__FILE__));
into a system plugin (onAfterInitialise Event) without luck.
What am i missing? Thanks!