Load page template file from package
Permalink
I am building a package that displays locations on a map based on page attributes using the page list block with a custom block template.
I want to load a page template file for the map page and another for the location page so that I can build out the layouts for these pages in the template files. Since this package does not include a theme, I am having difficulty getting Concrete5 to load the template files from the package. The page types and templates are both listed in Concrete5 and the composer form load properly when creating a new page. Unfortunately, the layout from the template files from the package is not loading, so all I am getting is the default template layout from the installed theme. Any help would be greatly appreciated!
This is build on Concrete5.7.5.13
Here is my file structure:
[Package root]
- blocks
- - page_list
- - - templates
- - - - page_list_map
- controller.php
- page_templates
- - location.php
- - locations_map.php
- single_pages
- - dashboard
- - - location_map
- - - - settings.php
- - - location_map.php
In my package controller, I have added code to setup the page template and page types
Function to add the template:
Function to add the page types:
I want to load a page template file for the map page and another for the location page so that I can build out the layouts for these pages in the template files. Since this package does not include a theme, I am having difficulty getting Concrete5 to load the template files from the package. The page types and templates are both listed in Concrete5 and the composer form load properly when creating a new page. Unfortunately, the layout from the template files from the package is not loading, so all I am getting is the default template layout from the installed theme. Any help would be greatly appreciated!
This is build on Concrete5.7.5.13
Here is my file structure:
[Package root]
- blocks
- - page_list
- - - templates
- - - - page_list_map
- controller.php
- page_templates
- - location.php
- - locations_map.php
- single_pages
- - dashboard
- - - location_map
- - - - settings.php
- - - location_map.php
In my package controller, I have added code to setup the page template and page types
Function to add the template:
public function addPageTemplates($pkg) { if (!is_object(PageTemplate::getByHandle('locations_map'))){ $pageTemplate = PageTemplate::add('locations_map', 'Locations Map (Default)', 'full.png', $pkg); } if (!is_object(PageTemplate::getByHandle('location'))){ $pageTemplate = PageTemplate::add('location', 'Location (Default)', 'full.png', $pkg); } }
Function to add the page types:
public function addPageTypes($pkg) { // Locations Map Page Type $mapPageType = PageType::getByHandle('lmpl_locations_map'); if (!is_object($mapPageType)) { $mapPageTemplate = PageTemplate::getByHandle('locations_map'); // Should match the template file name without the extension $mapPageType = PageType::add( array( 'handle' => 'lmpl_locations_map', 'name' => 'Locations Map', //Note: it does not appear you can pass the t() function in the name 'defaultTemplate' => $mapPageTemplate, // This should load the template file from the package 'allowedTemplates' => 'C', //A is all, C is selected only, X is not selected only. Defaults to A if key is not included 'templates' => array($mapPageTemplate), //So, in this case, with C above, ONLY the template listed can be used 'ptLaunchInComposer' => true, //optional, defaults to false, but need to set to true to display the composer form 'ptIsFrequentlyAdded' => false, //optional, defaults to false. Determines whether or not it shows up in the add page type frequent list 'ptPublishTargetTypeID' => 1,
Viewing 15 lines of 39 lines. View entire code block.