We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

API class changed from 2.1.0 to 2.1.3 ?

Development and Programming

Un.titled's avatar
Un.titled
34 posts
15 years ago
Un.titled's avatar Un.titled

Hi I created a module which utilised the api channel methods to insert entries into the system it was working well for 2.1.0 but now i’ve used it for another 2.1.3 project it’s throwing this error:

Message: Undefined index: field_type
Filename: api/Api_channel_fields.php
Line Number: 256

The code i pass into the api_channel_entries->submit_new_entry function is:

Array
(
    [author_id] => 1
    [title] => My Shoes 
    [url_title] => my-shoes
    [entry_date] => 1295866693
    [versioning_enabled] => n
    [year] => 2011
    [month] => 01
    [day] => 24
    [expiration_date] => 
    [comment_expiration_date] => 
    [status] => open
    [allow_comments] => n
    [field_id_16] => Black Leather
    [field_id_47] => 00111443
    [cp_call] => 1
    [channel_id] => 2
    [site_id] => 1
    [ping_servers] => Array
        (
        )

)

Have i missed something which is causing this to fall down?

(Yes I have checked that the custom field id’s are correct)

Moved to Development and Programming by Moderator

       
Un.titled's avatar
Un.titled
34 posts
15 years ago
Un.titled's avatar Un.titled

Just updated the code slightly, still erroring

Array
(
    [author_id] => 1
    [title] => Desert Boot   
    [url_title] => Desert-Boot---
    [entry_date] => 1295867744
    [versioning_enabled] => n
    [year] => 2011
    [month] => 01
    [day] => 24
    [expiration_date] => 
    [comment_expiration_date] => 
    [status] => open
    [allow_comments] => n
    [field_id_16] => Black Leather
    [field_ft_16] => none
    [field_id_47] => 00111443
    [field_ft_47] => none
    [cp_call] => 1
    [channel_id] => 2
    [site_id] => 1
    [ping_servers] => Array
        (
        )

)

N.B: included field_ft_16 and field_ft_47 set to ‘none’

       
Sue Crocker's avatar
Sue Crocker
26,054 posts
15 years ago
Sue Crocker's avatar Sue Crocker

Hi, Un.titled.

Moving this to the Development forum for additional community support.

       
Andrew Weaver's avatar
Andrew Weaver
206 posts
15 years ago
Andrew Weaver's avatar Andrew Weaver

This is how I run the channel entry API:

$this->EE->load->library('api');
        $this->EE->api->instantiate('channel_fields');
        $this->EE->api_channel_fields->fetch_custom_channel_fields();
        $this->EE->api->instantiate('channel_entries');
        $this->EE->api_channel_fields->settings = array(); 

        $data = array(
            'title' => 'A test entry',
            'entry_date' => '1256953732',
            'field_id_1' => 'Testing',
            'field_ft_1' => 'xhtml'
        );

Andrew

       
Un.titled's avatar
Un.titled
34 posts
15 years ago
Un.titled's avatar Un.titled
$this->EE->api_channel_fields->fetch_custom_channel_fields();
$this->EE->api_channel_fields->settings = array();

By adding these two lines this solved my problems, thanks Andrew.

Perhaps this should be added to the User Guide?

       
Robin Sowell's avatar
Robin Sowell
13,255 posts
15 years ago
Robin Sowell's avatar Robin Sowell

Yes- for the next release the api has been tweaked a bit, and the documentation will reflect that (a bit different from what you’ve done- but gist is same- make sure settings is properly populated). Thanks for the heads up- and sorry this one hung you up. Do double check the docs in the next release, as the changes affect some other issues that may crop up.

       
Ryan M.'s avatar
Ryan M.
1,511 posts
15 years ago
Ryan M.'s avatar Ryan M.

Can someone post a definitive answer on how to use (or if we can successfully use) the Channel Entries API in EE 2.1.3? Or update the docs with a complete example usage? I simply can’t get new entries inserted without errors. After tweaking line 941 per a bug report in another thread, my entries are getting added, but this error (notice) is still cropping up:

Severity: Notice
Message:  Undefined index: field_fmt
Filename: api/Api_channel_entries.php
Line Number: 944

ExpressionEngine 2.1.3 build 20101220

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.