I need to add some code to a template in order to submit a new entry under certain conditions. I thought I would use this function:
$this->EE->api_channel_entries->submit_new_entry((int) $channel_id, (mixed) $data);The User Guide says that in order to call the class I need to instantiate it first:
$this->EE->load->library('api');
$this->EE->api->instantiate('channel_entries');That’s fine, but how do I embed this code in a template?
I am not developing a plugin, an extension or a module, I am simply relying on this class to get some work done in a template.
Thank you for your help! Franco
You can use PHP in templates. Because you can use PHP, you can call get_instance(), and because you can call get_instance(), you can access anything inside your CodeIgniter system. ExpressionEngine is, after all, a CodeIgniter app.
$EE =& get_instance();
$EE->load->library('form_validation');
$EE->load->library('xmlrpc');
$EE->load->helper('url');
// ...Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.