Template Group Model
class ExpressionEngine\Model\Template\TemplateGroup
Properties
Required
group_name
site_id
Optional
group_id
Keygroup_order
is_site_default
Relationships
Roles
Roles with access to the group.
Templates
Templates in the Template Group
Site
The site the group belongs to.
Methods
ensureFolderExists
getFolderPath
validateTemplateGroupName
validateUnique
Events
beforeInsert
afterDelete
afterInsert
afterUpdate
afterSave
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();
}