Legacy Documentation
You are using the documentation for version 4.3.8. Go here for the latest version.
ExpressionEngine Channel Structure API¶
Calling the Class¶
- 
class Api_channel_structure¶
- The Channel Structure class is called with the - api->instantiate()function:- ee()->load->library('api'); ee()->legacy_api->instantiate('channel_structure'); 
Function Reference¶
Get Channel Info¶
- 
Api_channel_structure::get_channel_info($channel_id)¶
- Fetches all metadata for a channel: - ee()->api_channel_structure->get_channel_info((int) $channel_id); - Parameters: - $channel_id (int) – ID of the channel to fetch information for
 - Returns: - Database result object or - FALSEon error- Return type: - CodeIgniter database result object 
Get Channels¶
- 
Api_channel_structure::get_channels([$site_id = FALSE])¶
- Fetches channel names and ids: - ee()->api_channel_structure->get_channels([(int) $site_id]); - Parameters: - $site_id (int) – The site ID you want channel information for
 - Returns: - Database result object or - FALSEon error- Return type: - CodeIgniter database result object 
Delete Channel¶
- 
Api_channel_structure::delete_channel($channel_id = ''[, $site_id = NULL])¶
- Delete a channel: - ee()->api_channel_structure->delete_channel((int) $channel_id, [(int) $site_id]); - Parameters: - $channel_id (int) – ID of the channel to delete
- $site_id (int) – Specify the site ID of the channel if necessary
 - Returns: - Channel Title on successful delete or - FALSEon error.- Return type: - String/Boolean 
Create Channel¶
- 
Api_channel_structure::create_channel($data)¶
- Creates a new channel: - ee()->api_channel_structure->create_channel((array) $data); - Parameters: - $data (array) – Array of data necessary to create a channel (see below)
 - Returns: - ID of newly created channel or - FALSEon error.- Return type: - Integer/Boolean - At the minimum, - channel_titleand- channel_namemust 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' => 'https://example.com/news/', 'status_group' => 1 ); if (ee()->api_channel_structure->create_channel($data) === FALSE) { show_error('An Error Occurred Creating the Channel'); } 
Modify Channel¶
- 
Api_channel_structure::modify_channel($data)¶
- Update an existing Channel: - ee()->api_channel_structure->modify_channel((array) $data); - Parameters: - $data (array) – Channel modification data (see
Api_channel_structure::create_channel’s data array examples)
 - Returns: - ID of newly created channel or - FALSEon error- Return type: - Integer/Boolean - The - channel_idof the channel to be modified is required in the $data array.- channel_titleand- channel_nameare also required.- In addition to values in the - exp_channelstable, values that may be modified include:- apply_expiration_to_existing, (- bool) only if- comment_expirationis set
- clear_versioning_data, (- bool)
 
- $data (array) – Channel modification data (see