ExpressionEngine Docs

Template Group Model

class ExpressionEngine\Model\Template\TemplateGroup

Properties

Required

Optional

Relationships

Roles

Roles with access to the group.

Templates

Templates in the Template Group

Site

The site the group belongs to.

Methods

Events

Examples

Get a Template Group

$group = ee('Model')->get('TemplateGroup')->filter('group_name', 'about')->first();

Modify the Group Name

// Get the group object.
$group = ee('Model')->get('TemplateGroup')->filter('group_name', 'about')->first();

// Change the name.
$group->group_name = 'newgroupname';

// Validate and Save the template.
$result = $group->validate();

if ($result->isValid())
{
  $group->save();
}

Create a New Template Group

// Make a new template object.
$group = ee('Model')->make('TemplateGroup');

// Add the required fields.
$group->group_name = 'mytemplates';
$group->site_id    = ee()->config->item('site_id');

// Validate and Save the template.
$result = $group->validate();

if ($result->isValid())
{
  $group->save();
}