5.7.3.1 - Error on create page - getPageTemplateID()

Permalink 1 user found helpful
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...

 
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..
brandscapes replied on at Permalink Reply
brandscapes
I see this thread is 4 years old and hope someone is still following it.

I get same error, "Call to a member function getPageTemplateID() on null", and sometimes also error stating I don't have permission to post a page here.

My scenario was that I deleted a page to do it over then went to trash and emptied it so I could create a page with the same name and that's when errors started.

I am a novice and don't understand the resolutions and can't get this fixed, can anyone go into more detail and tell me where I need to go to resolve?

Thank you.
Kiesel replied on at Permalink Reply
1. Download SQLyog community edition (free). Install and open it.
2. Make a new connection (ctrl+m) to your database. Give in your username/password and host address. If you have no idea what the data is you might need to ask your server hosting provider.
3. Connect to it
4. In the big white field in the middle of your screen (Tab with the name "Query") type the following: Select * from page_templates
5. Hit F9, so it processes this query
6. You should see now data to all your page templates. Choose one as your new default and read out the id of it. I don't think it matters much which one you choose.
7. Use this Id now by writing a new query into the big white field in the middle of your screen. Let's say you chose the template with Id 19. Write: Update PageTypes set ptDefaultPageTemplateID =19 where ptHandle="page"
8. Press again F9. If no error message comes it's done.

That's it. But that only works if your concrete version is somewhere along the line of what it was at the time of this post and if your problem is really the same. Don't think it would work in current versions.
brandscapes replied on at Permalink Reply
brandscapes
This is what I'm running:

# concrete5 Version
Core Version - 8.2.1
Version Installed - 8.2.1
Database Version - 20170802000000

# concrete5 Packages
C5DK Blog (8.3.2), Call Me (0.9.6), Equinox (1.0.5), Social Stream (1.2.1), Spacer (0.9.4), Whale OWL Carousel (2.5.8)

# concrete5 Overrides
blocks/call_me/templates/equinox/view.css, blocks/call_me/templates/equinox, blocks/call_me/templates, blocks/call_me

# concrete5 Cache Settings
Block Cache - On
Overrides Cache - On
Full Page Caching - Off
Full Page Cache Lifetime - Every 6 hours (default setting).

# Server Software
Apache

# Server API
litespeed

# PHP Version
7.1.26

# PHP Extensions
bcmath, bz2, calendar, Core, ctype, curl, date, dom, exif, fileinfo, filter, ftp, gd, gettext, gmp, hash, iconv, imap, intl, json, libxml, litespeed, mbstring, mcrypt, mysqli, openssl, pcntl, pcre, PDO, pdo_mysql, pdo_pgsql, pdo_sqlite, pgsql, Phar, posix, readline, Reflection, session, shmop, SimpleXML, soap, sockets, SPL, sqlite3, standard, tidy, tokenizer, xml, xmlreader, xmlrpc, xmlwriter, xsl, zip, zlib

# PHP Settings
max_execution_time - 300
log_errors_max_len - 1024
max_file_uploads - 20
max_input_nesting_level - 64
max_input_time - -1
max_input_vars - 10000
memory_limit - 768M
post_max_size - 128M
sql.safe_mode - Off
upload_max_filesize - 128M
mysqli.max_links - Unlimited
mysqli.max_persistent - Unlimited
pcre.backtrack_limit - 1000000
pcre.recursion_limit - 100000
pgsql.max_links - Unlimited
pgsql.max_persistent - Unlimited
session.cache_limiter - <i>no value</i>
session.gc_maxlifetime - 7200
soap.wsdl_cache_limit - 5
brandscapes replied on at Permalink Reply
brandscapes
and P.S. I looked for SQLyog Community Edition....I'm on a MacBook Pro.

Sounds like a simple fix, can I hire someone to fix? Also checking into restoring backup through the host, I'll lose a few blog pages but can fix.
Kiesel replied on at Permalink Reply
Sorry, no idea what to use on a Mac if that can't be installed. But basically any MariaDB or MySQL database query software should work.

Also, I don't know if those specs work or not, it's been a long time. I guess if you can find the database tables in your version it should work.
brandscapes replied on at Permalink Reply
brandscapes
Thank you everyone for offering to help out. I got the issue resolved. Found a local developer that uses Concrete5 and he was able to use one of the above solutions.

I have two backups in the rotation now so I have one to fall back on.