Inxentas Posted October 2, 2020 Share Posted October 2, 2020 I seem to have some issues with the use of $config->usePageClasses introduced in ProcessWire 3.0.167. I've set it to true so I can use Page Classes. Works perfectly on my own machine, but not on my Staging server. I get the following error: Look out… Error: Exception: Method Page::renderHeading does not exist or is not callable in this context (in wire/core/Wire.php line 544) The method renderHeading() is part of the DefaultPage class. It seems the staging server ignores the classes entirely, as a var_dump() turns out the page is not of the DefaultPage class but the standard Page class. I have no real idea where to look for the issue, does anyone have an idea on how to debug this? The only difference between my Local machine and the Staging server is that it uses a different MySQL database to connect to. Here is the class in full: <?php namespace ProcessWire; class DefaultPage extends Page { /** * Renders a heading based on any title and an optional blurb. * * @param type $title * @param type $blurb * @return string */ public function renderHeading($title, $blurb = null) { $html = ''; $html .= '<div class="content"><div class="layout"><div class="intro"><div class="narrow">'; if ($title != null) { $html .= '<div class="big"><h2>'.$title.'</h2></div>'; } $html .= '<div class="divider"><div class="inner"></div></div>'; if ($blurb != null) { $html .= '<div class="blurb">'.$blurb.'</div>'; } $html .= '</div></div></div></div>'; return $html; } /** * Renders a Project page for the Collection Page grid. * * @param type $col * @param type $row * @param type $project * @return string */ public function renderProject($col, $row, $project) { $html = ''; $html .= '<div class="project project_'.$col.'_'.$row.'">'; $html .= '<a class="inner" href="'.$project->url.'">'; if ($project->image_header) { $html .= '<span class="background" style="background-image:url(\'' . $project->image_header->width(600)->url . '\')"></span>'; } $html .= '<span class="background" style="background-color:rgba(0,0,0,0.2);"></span>'; $html .= '<span class="inner">'; $html .= '<h2>' . $project->title . '</h2>'; $html .= '<div>' . $project->meta_description . '</div>'; $html .= '</span>'; $html .= '<a class="link" href="' . $project->url . '">View</a>'; $html .= '</a>'; $html .= '</div>'; return $html; } } When I add a specific class for the homepage and let it extend DefaultPage... <?php namespace ProcessWire; class PageHomePage extends DefaultPage { } I get the following error: Well well… Fatal Error: Class 'DefaultPage' not found (line 3 of site/classes/PageHomePage.php) It seems the DefaultPage class cannot be found/loaded. Link to comment Share on other sites More sharing options...
Inxentas Posted October 2, 2020 Author Share Posted October 2, 2020 Typical. Just as I submit the topic, I find the solution. Turns out I just made a CamelCase boo boo with the filename: Defaultpage.php had to be DefaultPage.php. Sorry to waste your time. 2 Link to comment Share on other sites More sharing options...
teppo Posted October 3, 2020 Share Posted October 3, 2020 23 hours ago, Inxentas said: Turns out I just made a CamelCase boo boo with the filename: Defaultpage.php had to be DefaultPage.php. Sorry to waste your time. I'm really starting to think that camel case / pascal case should be avoided... well, just about everywhere ? Recently ran into a similar issue where a piece of code worked flawlessly on my machine, yet on the live server it spat out nonsensical errors. Turns out my local (Mac) env is case insensitive (which also applies to the virtual machine I use to run Linux on it) while the server is case sensitive. Spent half an hour or so debugging the issue and tearing things apart just to find a tiny typo in the filename. So frustrating! ? 2 Link to comment Share on other sites More sharing options...
Inxentas Posted October 5, 2020 Author Share Posted October 5, 2020 Ha ha yes, I feel so silly because this isn't the first time this exact issue has caused me to look for the culprit for about an hour, to finally post on a forum in desperation... only to find the bloody typo just 5 minutes later! I'm alwats torn between blaming Windows / MacOS for not being case sensitive and exact enough, or myself for sticking with CamelCase. Thanks for understanding ? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now