Concrete5.7.2.1 create post/page programmatically.
Permalink
I have a small project and would need someone to help me out. See the attached screenshots.
I have an Animal page type with fields on the second screenshot.
Also posting a controller to create a new animal page.
I would need to add content also to Thumbnail, Content and HTML fields.
If I use following code it will just add additional block to the page ... but the build in to the page type will remain empty.
I have an Animal page type with fields on the second screenshot.
Also posting a controller to create a new animal page.
I would need to add content also to Thumbnail, Content and HTML fields.
namespace Application\Controller\SinglePage; use \Concrete\Core\Page\Controller\PageController; use \Concrete\Core\Page\Type\Type as CollectionType; use Loader; use Page; use PageList; use BlockType; class CreatePage extends PageController { public function view() { $animalsPage = Page::getByPath("/animals"); $collectionType = CollectionType::getByHandle('animal'); $pageData = array(); $pageData['cName'] = 'New animal | '.date('h:i:s'); $pageData['cDescription'] = 'New animal | '.date('h:i:s');
Viewing 15 lines of 25 lines. View entire code block.
If I use following code it will just add additional block to the page ... but the build in to the page type will remain empty.
$block = BlockType::getByHandle('html'); $data = array( 'content' => '<p>test block</p>', ); $newBlock = $page->addBlock($block, "Main", $data);