How ro render specified item?

More
13 years 3 months ago #30133 by dkom
Replied by dkom on topic How ro render specified item?
Code:
require_once(JPATH_ADMINISTRATOR.DS."components/com_flexicontent/models/items.php"); require_once(JPATH_ADMINISTRATOR.DS."components/com_flexicontent/controllers/items.php"); $c = new FlexiContentControllerItems(); $itemmodel = $c->getModel('item');

This code works fine.
Now I'll try to integrate it with templates, thank you for help.

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

More
13 years 3 months ago #30149 by dkom
Replied by dkom on topic How ro render specified item?
Strange... I want to display selected item with template, but get an error:
Code:
$itemmodel = $c->getModel('item'); $item = $itemmodel->getItem($itemId, $check_view_access=false); $items = array(&$item); FlexicontentFields::getFields($items); require_once(JPATH_ADMINISTRATOR.DS."components/com_flexicontent/models/itemelement.php"); $view = new FlexicontentViewItem(); $view->setModel($itemmodel); print_r($view->display()); die;

$view->display
raises
Fatal error: Call to a member function get() on a non-object in /joomla-path/components/com_flexicontent/views/item/view.html.php on line 68

it seems getModel() returns null even I have set it before.

Could you explain what am I doing wrong?

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

More
13 years 3 months ago #30156 by ggppdk
Do not try to render the item yet, since i have not tested or verified what is needed to do it,

they way it is done in category view (view.html.php)
(to render the item view of an item)
is to capture PHP output via ob_start() etc

if you want to try this you are on your own, we can not test this now,

plus consider that loading item.css from different template layouts may cause problems


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

More
13 years 3 months ago #30285 by ggppdk
Try this,
it works, but some changes to it to make it independent have not been tested, it may need corrections:

How to render item view in custom code


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

More
13 years 3 months ago #30297 by ggppdk
Ok i have decided to add a function
renderItem in class flexicontent_html:

you can use like:
Code:
require_once (JPATH_ADMINISTRATOR.DS.'components/com_flexicontent/defineconstants.php'); JTable::addIncludePath(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_flexicontent'.DS.'tables'); require_once("components/com_flexicontent/classes/flexicontent.fields.php"); require_once("components/com_flexicontent/classes/flexicontent.helper.php"); require_once("components/com_flexicontent/models/".FLEXI_ITEMVIEW.".php"); $itemid = 471; $flexi_html_helper = new flexicontent_html(); $item_html = $flexi_html_helper->renderItem($itemid); echo $item_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 review. Thanks!

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

Moderators: vistamediajoomlacornerggppdk
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
Save