New FlexicontentModelItem issue

4 weeks 1 day ago #77312 by riiich
I have a custom module that generates widgets based on item selection. One of the methods is by selecting articles which store their IDs. I have an array of article IDs, and then I loop them and store them as flexicontent items.

require_once (JPATH_ADMINISTRATOR.DS.'components'.DS.'com_flexicontent'.DS.'models'.DS.'item.php');
 
$itemModel  = new FlexicontentModelItem();
$items      = [];
$articleIds = [200, 218, 221, 222];
 
foreach ($articleIds as $articleId) {
  $items[] = $itemModel->getItem($articleId, $check_view_access=false, $no_cache=true, $force_version=0);
}

For some reason this works perfectly fine with certain articles, but other times I get this error:

Call to undefined method FlexicontentModelItem::decideLayout()

I've checked and the articles are published and perfectly valid, so I can't see what the issue is. Any ideas?

Thanks.

Please Log in or Create an account to join the conversation.

4 weeks 1 day ago #77313 by riiich
Apologies, I think I found my issue. I hadn't included either the other or the correct required files:

if (!defined('DS'))  define('DS',DIRECTORY_SEPARATOR);
require_once (JPATH_ADMINISTRATOR.DS.'components'.DS.'com_flexicontent'.DS.'defineconstants.php');
require_once (JPATH_SITE.DS.'components'.DS.'com_flexicontent'.DS.'helpers'.DS.'route.php');
require_once (JPATH_SITE.DS.'components'.DS.'com_flexicontent'.DS.'classes'.DS.'flexicontent.helper.php');
require_once (JPATH_SITE.DS.'components'.DS.'com_flexicontent'.DS.'classes'.DS.'flexicontent.fields.php');
require_once (JPATH_SITE.DS.'components'.DS.'com_flexicontent'.DS.'classes'.DS.'flexicontent.categories.php');
 
require_once (JPATH_SITE.DS.'modules'.DS.'mod_flexicontent'.DS.'classes'.DS.'datetime.php');
JLoader::register('JFormFieldFclayoutbuilder', JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_flexicontent' . DS . 'elements' . DS . 'fclayoutbuilder.php');
 
require_once (JPATH_SITE.DS.'components'.DS.'com_flexicontent'.DS.'models'.DS.'item.php');
require_once (JPATH_SITE.DS.'components'.DS.'com_flexicontent'.DS.'models'.DS.'category.php');

Please Log in or Create an account to join the conversation.

4 weeks 1 day ago #77314 by ggppdk


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star review. Thanks!

Please Log in or Create an account to join the conversation.

Moderators: vistamediajoomlacornerggppdk
© 2018 Flexicontent. All Rights Reserved.