ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

submit_new_entry unclear docs

October 28, 2012 2:04pm

Subscribe [3]
  • #1 / Oct 28, 2012 2:04pm

    okaris

    4 posts

    This is the example taken from the docs on plugin creation. What i want is to have a cron job to gather some information and create an entry. 

    $this->EE->load->library('api');
            $this->EE->api->instantiate('channel_entries');
            $this->EE->api->instantiate('channel_fields');
    
            $data = array(
             'title'         => 'Breaking News Story!',
             'entry_date'    => '1256953732',
             'field_id_6'    => 'Some data',
             'field_ft_6'    => 'none',
             'field_id_19'   => 'More data',
             'field_ft_19'   => 'xhtml'
             );
    
             $this->EE->api_channel_fields->setup_entry_settings($channel_id, $data);
    
             if ($this->EE->api_channel_entries->submit_new_entry($channel_id, $data) === FALSE)
             {
              show_error('An Error Occurred Creating the Entry');
             }

    Questions are

    How do I know these ids

    'field_id_6'    => 'Some data',
             'field_ft_6'    => 'none',
             'field_id_19'   => 'More data',
             'field_ft_19'   => 'xhtml'

    How do i know the channel_id? Is there a way to get the id of a channel by name or do i need to memorize the id of each channel i have?

    Cheers

  • #2 / Oct 28, 2012 7:10pm

    ahmad saad

    364 posts

    How do I know these ids

    'field_id_6'    => 'Some data',
             'field_ft_6'    => 'none',
             'field_id_19'   => 'More data',
             'field_ft_19'   => 'xhtml'

    you can find this Id from channel fields page, the id column is the number you must append to field_id_ and field_ft_

  • #3 / Oct 30, 2012 10:58am

    Shane Eckert

    7174 posts

    Hey there okaris,

    Looks like Ahmad was able to help you out!

    Is there anything else you need?

    Thank you,

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases