xb385
July 13, 2022, 10:31pm
1
Hi, ive been looking through the documentation and cheatsheets but i can’t find a way to programmatically add containers…anyone got any idea how, i was thinking something like the following should be possible:
$pTemplate = PageTemplate::getByHandle(‘three_column’);
if(!$pTemplate) {
PageTemplate::add(‘three_column’, t(‘Three Column’), ‘three_column.png’, $pkg = null);
}
hutman
July 14, 2022, 1:34pm
2
There are 2 files in the code I can find where a new container is created, doesn’t look quite as simple as some other things.
<?php
namespace Concrete\Controller\SinglePage\Dashboard\Pages\Containers;
use Concrete\Core\Entity\Page\Container;
use Concrete\Core\Page\Container\Command\AddContainerCommand;
use Concrete\Core\Page\Container\Command\ContainerCommandValidator;
use Concrete\Core\Page\Controller\DashboardPageController;
class Add extends DashboardPageController
{
public function view()
{
$this->set('tokenMessage', 'add_container');
$this->render('/dashboard/pages/containers/form');
}
public function add_container()
{
if ($this->token->validate('add_container')) {
This file has been truncated. show original
If you have a package it might be easier to just do it using the CIF stuff like they do in the Atomik
https://github.com/concretecms/concretecms/blob/9.1.0/concrete/config/install/packages/atomik_full/content.xml (around line 447)
2 Likes
xb385
July 15, 2022, 1:25pm
3
Thx hutman, that really helps!