Load two different files with the different base locations but with same name.
JLoader::import('somemodel', JPATH_ROOT.'/components/com_mycomponent1/models');
JLoader::import('somemodel', JPATH_ROOT.'/components/com_mycomponent2/models');
Models from each component are loaded and can be used.
JModelLegacy::getInstance( 'somemodel', 'MyComponent2Model' ); should result model object.
JModelLegacy::getInstance( 'somemodel', 'MyComponent2Model' ); results in false value
Joomla 3.8.5
| Labels |
Added:
?
|
||
| Category | ⇒ | com_plugins |
| Status | New | ⇒ | Information Required |
@corejoomla can this Issue be closed?
Thanks for the clarifications. This issue can be closed.
| Status | Information Required | ⇒ | Closed |
| Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2018-03-03 16:58:47 |
| Closed_By | ⇒ | corejoomla |
JLoader::import()works with a dot separated key to load files, it is the class method used byjimport(), so its proper use would beJLoader::import('joomla.filesystem.file')(note the method also has very explicit class name expectations, component model classes wouldn't fit the convention).You should either use
JLoader::register()to register class names to the autoloader, orJModelLegacy::addIncludePath()to register the lookup paths for your models.