Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure com_content models are in lookup path #9519

Merged
merged 1 commit into from Mar 22, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 13 additions & 4 deletions modules/mod_related_items/helper.php
Expand Up @@ -9,7 +9,7 @@

defined('_JEXEC') or die;

require_once JPATH_SITE . '/components/com_content/helpers/route.php';
JLoader::register('ContentHelperRoute', JPATH_SITE . '/components/com_content/helpers/route.php');

/**
* Helper for mod_related_items
Expand All @@ -25,7 +25,7 @@ abstract class ModRelatedItemsHelper
*
* @param \Joomla\Registry\Registry &$params module parameters
*
* @return array
* @return array
*/
public static function getList(&$params)
{
Expand All @@ -37,8 +37,16 @@ public static function getList(&$params)
$maximum = (int) $params->get('maximum', 5);

// Get an instance of the generic articles model
JModelLegacy::addIncludePath(JPATH_SITE . '/components/com_content/models');
$articles = JModelLegacy::getInstance('Articles', 'ContentModel', array('ignore_request' => true));

if ($articles === false)
{
JFactory::getApplication()->enqueueMessage(JText::_('JERROR_AN_ERROR_HAS_OCCURRED'), 'error');

return array();
}

// Set application parameters in model
$appParams = $app->getParams();
$articles->setState('params', $appParams);
Expand Down Expand Up @@ -71,7 +79,7 @@ public static function getList(&$params)
{
JFactory::getApplication()->enqueueMessage(JText::_('JERROR_AN_ERROR_HAS_OCCURRED'), 'error');

return;
return array();
}

// Explode the meta keys on a comma
Expand Down Expand Up @@ -144,6 +152,7 @@ public static function getList(&$params)
}

$db->setQuery($query, 0, $maximum);

try
{
$temp = $db->loadObjectList();
Expand All @@ -152,7 +161,7 @@ public static function getList(&$params)
{
JFactory::getApplication()->enqueueMessage(JText::_('JERROR_AN_ERROR_HAS_OCCURRED'), 'error');

return;
return array();
}

if (count($temp))
Expand Down