New FlexicontentModelItem issue

More
4 years 5 months 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.

Code:
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:

Code:
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.

More
4 years 5 months ago #77313 by riiich
Apologies, I think I found my issue. I hadn't included either the other or the correct required files:

Code:
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.

More
4 years 5 months ago #77314 by ggppdk
Hello

yes , for completeness i link to the relevant FAQ article
flexicontent.org/documentation/tutorials...-in-custom-code.html


-- 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...

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

Moderators: vistamediajoomlacornerggppdk
Time to create page: 0.272 seconds
Save
Cookies user preferences
We use cookies to ensure you to get the best experience on our website. If you decline the use of cookies, this website may not function as expected.
Accept all
Decline all
Essential
These cookies are needed to make the website work correctly. You can not disable them.
Display
Accept
Analytics
Tools used to analyze the data to measure the effectiveness of a website and to understand how it works.
Google Analytics
Accept
Decline