ExpressionEngine

2.5.5 User Guide

ExpressionEngine Channel Structure API

Calling the Class

The Channel Structure class is called with the api->instantiate() function.

$this->EE->load->library('api'); $this->EE->api->instantiate('channel_structure');

Function Reference

Get Channel Info

$this->EE->api_channel_structure->get_channel_info((int) $channel_id);
returns:Database result object or FALSE on error.

Get Channels

$this->EE->api_channel_structure->get_channels([(int) $site_id]);
returns:Database result object or FALSE on error.

Delete Channel

$this->EE->api_channel_structure->delete_channel((int) $channel_id, [(int) $site_id]);
returns:Channel Title on successful delete or FALSE on error.

Create Channel

$this->EE->api_channel_structure->create_channel((array) $data);
returns:ID of newly created channel or FALSE on error.

At the minimum, channel_title and channel_name must be in the $data array.

Values that may be passed in the data array include:

  • site_id, (int)

  • channel_title, (string)

  • channel_name, (string a-zA-Z0-9_- only)

  • url_title_prefix, (string a-zA-Z0-9_- only)

  • comment_expiration, (int)

  • create_templates, (string yes/no)

    Also Requires:

    • old_group_id
    • group_name, (string a-zA-Z0-9_- only)
    • template_theme
  • cat_group, (int or array of category group ids)

  • dupe_id

  • status_group

  • field_group

  • channel_url

  • channel_lang

  • group_order

Example Usage:

$data = array(
        'channel_title'     => 'News',
        'channel_name'      => 'news',
        'field_group'       => 2,
        'channel_url'       => 'http://example.com/index.php/news/',
        'status_group'      => 1
);

if ($this->EE->api_channel_structure->create_channel($data) === FALSE)
{
        show_error('An Error Occurred Creating the Channel');
}

Modify Channel

$this->EE->api_channel_structure->modify_channel((array) $data);
returns:ID of newly created channel or FALSE on error.

The channel_id of the channel to be modified is required in the $data array. channel_title and channel_name are also required.

In addition to values in the exp_channels table, values that may be modified include:

  • apply_expiration_to_existing, (bool) only if comment_expiration is set
  • clear_versioning_data, (bool)