5.7.3.1 - Error on create page - getPageTemplateID()

Permalink
When I try to create a new site it all goes first well and I get the popup in which I can add the page name, choose a page template, etc...

But when pressing the final button to create the site I get the following error message:

{"error":{"message":"Call to a member function getPageTemplateID() on a non-object"},"errors":["Call to a member function getPageTemplateID() on a non-object"]}

No matter what page type I choose, it's always the same error. I have to add to this, that I did delete a few of the existing page types (left_sidebar, right_sidebar, ...) before that error started to show up. But I didn't delete the ones I was using, only the ones I thought the client will not need. So this error needs to be connected I guess...

View Replies: View Best Answer
Juha replied on at Permalink Reply
Juha
If this is still an issue, try clearing cache first.

I ran into a similar problem once when I deleted some page templates that were in use, so if clearing the cache doesn't help I would try adding the deleted templates or page types back and see if that makes any difference.
Kiesel replied on at Permalink Reply
Thanks for the answer and try to help. I've cleared all the cache, set cache modes all on off, cleared the browser cache, restarted browser, tried other browser.

All that did help was to play a backup of the whole site in. That worked ;)
farion replied on at Permalink Reply
farion
Same problem here and no solution yet.
farion replied on at Permalink Best Answer Reply
farion
Found the solution.

Seems that the Page Type "Page" does have the wrong default template active.
Unfortunately if you change that via GUI, you ran to the same error (Themes > Page Types > Page Details)

Seems this happens if you delete the default page type.

The solution was to fix the id in the database.

First get the ID from a template that you want to chose as default (SELECT * FROM PageTemplates). E.g. 19
Now you have to change the default id (UPDATE PageTypes SET ptDefaultPageTemplateID = 19 WHERE ptHandle="page").

Hope that helps. Without guarantee.
Kiesel replied on at Permalink Reply
Thanks for sharing. I'll give that a try when I clean up the page templates the next time. I think I didn't delete the default template, but who knows, it's not called "default" anymore in the German language.
tsdonohue5 replied on at Permalink Reply
Excellent! This fix worked.

I like to clean up templates by deleting un-used page types and page templates but this cleaning caused the problem by deleting the default page template.

I will try to avoid deleting the default page type from now on.
Kiesel replied on at Permalink Reply
Ran into the same problem again and this time tried your fix. And it worked! Thanks!
okapi replied on at Permalink Reply 1 Attachment
okapi
I ran into the same problem with Concrete5 5.7.4 RC2, after renaming a page template.
I couldn't create pages anymore, the error message was:

{"error":{"message":"Call to a member function getPageTemplateID() on a non-object"},"errors":["Call to a member function getPageTemplateID() on a non-object"]}

I followed your advice, but i found that the default ID was correct, instead i noticed a "C" in the table row "AllowedPageTemplates" for the page type "Page". Changing it to "A" solved the problem.

Actually i have no clue why that worked and what A or C means in ptAllowedPageTemplates...
davepilbeam replied on at Permalink Reply
davepilbeam
Just had same problem recently, unfortunately the fixes above didn't apply; in the end I got it working by replacing the database PageTemplates table with a backup.
I have now learnt to treat Page Template deletion with more caution..