Adding a page template in a package

Permalink
I can add a Page Template in a package:
if (!is_object(PageTemplate::getByHandle('my_template'))){
   $pt = PageTemplate::add('my_template', 'My Template', 'landing.png');
}


When that runs in the package controller the new template shows up in the dashboard page templates section. But, where in my package do I put the file for the template, my_template.php

Thanks in advance for any help someone can give!

pvernaglia
 
MichaelG replied on at Permalink Reply
MichaelG
womp womp. Yeah that doesn't exist. I think that changes with 7.4 though and packages get a page_templates folder.
MichaelG replied on at Permalink Reply
MichaelG
https://github.com/concrete5/concrete5-5.7.0/issues/1832
pvernaglia replied on at Permalink Reply
pvernaglia
Thanks Michael, It feels like we need a page_templates folder. Can't wait for 5.7.4 to fix all these little things!
MissMarvels replied on at Permalink Reply
MissMarvels
Is this one fixed?

https://github.com/concrete5/concrete5/issues/1832...

I still cannot install templates from page_templates, correct?
pvernaglia replied on at Permalink Reply
pvernaglia
Yes, it works now. Make a directory 'page_templates' in your package and put your template file in it (template_file.php).

if (!is_object(PageTemplate::getByHandle('template_file'))){
    $pageTemplate = PageTemplate::add('template_file', 'New Page Template', 'landing.png', $pkg);   
}
MissMarvels replied on at Permalink Reply
MissMarvels
Ill give that a try, tnx.

Op vr 17 jul. 2015 13:47 schreef concrete5 Community <
discussions@concretecms.com>:
zanedev replied on at Permalink Reply
zanedev
did this work for you? for me it installs the page template to the db but it doesn't use the actual template file until you manually copy it over to your theme where other template files live.
andrew replied on at Permalink Reply
andrew
Just out of curiosity...what kind of package has a page template that's completely decoupled from a theme? If you're also installing a theme you should really put the landing.php file in the theme itself?
pvernaglia replied on at Permalink Reply
pvernaglia
In my case it is a forum add on that adds a forum_post page type and a forum_post page template. Isn't landing.php one of the default icons that displays on the Page Templates Dashboard page?

It works, but my not be the best way of doing it?
andrew replied on at Permalink Reply
andrew
That makes sense. We've done this kind of thing in the past for add-ons like the calendar, so I'm not saying it's always a bad idea, just wanting to make sure it was all being done for the right reasons.
Pluto replied on at Permalink Reply
Pluto
Hello andrew,

I am replying, actually questioning to a very old comment.
I have created a page_templates folder in my custom add on. Then I copied the default.php file from elemental theme and paste the file into page_template directory forlder of my custom add on and rename the file to template_file.php.

In my custom add on controller in installation function I have wrote
if (!is_object(PageTemplate::getByHandle('location_template_file'))){
$pageTemplate = PageTemplate::add('template_file', 'New Page Template', 'landing.png', $pkg);
}

A page template is creating after installation. But if I am changing any thing in the template_file.php it is not reflecting in the page that i have created with the page template.
agencecoteo replied on at Permalink Reply
agencecoteo
Think the problem is that the call is made for packageHandle/pages_templates/pageTypeHandle.php instead of packageHandle/pages_templates/pageTemplateHandle.php.

I make a pull request :https://github.com/concrete5/concrete5/pull/5143... to fix that.