Package Controller, Page Templates...and Page Types
Permalink
Okay so I took a page from this how-to on reliable package installation and updates:https://www.concrete5.org/documentation/how-tos/developers/reliable-... which worked well for c5 5.6 and below.
I've managed to get things working well with everything except page templates.
Adding each template individually works fine like this:
Running the code with an array doesn't seem to work, OR I am going about it all wrong, which is what I hope is the case.
My public function looks like this:
This get me an error of: Object of class Concrete\Package\My_Theme\Controller could not be converted to string. Using the old method with Collection Type is a whole other error.
Any thoughts?
I've managed to get things working well with everything except page templates.
Adding each template individually works fine like this:
if (!is_object(PageTemplate::getByHandle('right_sidebar'))){ $pt = PageTemplate::add('right_sidebar', 'Right Sidebar'); }
Running the code with an array doesn't seem to work, OR I am going about it all wrong, which is what I hope is the case.
My public function looks like this:
protected $pagetemplates = array( 'complex'=>'Complex', 'right_sidebar'=>'Right Sidebar', 'left_sidebar'=>'Left Sidebar', 'full'=>'Full' ); // add page types from array public function configurePageTemplates($pkg) { foreach($this->pagetemplates as $key => $pagetemplates) { $pt = PageTemplate::getByHandle($key); if(!is_object($pt)) { $data['pTemplateHandle'] = $key; $data['pPageTemplateName'] = t($pagetemplates); $pt = PageTemplate::add($data,$pkg); }
Viewing 15 lines of 17 lines. View entire code block.
This get me an error of: Object of class Concrete\Package\My_Theme\Controller could not be converted to string. Using the old method with Collection Type is a whole other error.
Any thoughts?
Here is the reference I used to come up with this: http://concrete5.org/api/class-Concrete.Core.Page.Template.html...