Page Type Controller not working as expected

Permalink
I've just installed 5.7.2 to see what the differences are, and have tried to set up a page controller for a new new page type called home. When I am on the homepage, it is correctly using the home.php page view, but does not display the $pageTitle variable set in the controller at this location:
/application/controllers/page_types/home.php
Although, when in the dashboard and viewing the page type defaults via:
Pages & Themes => Page Types => Home => Output => Homepage (Page Templete) => Edit Defaults, the variable I am setting is visible on the page.
The variable is just called $pageTitle.

This is the code of the controller, in it's entirety:
<?php
namespace Application\Controller\PageType;
use Concrete\Core\Page\Controller\PageTypeController;
use Loader;
use Page;
use Permissions;
use View;
class Home extends PageTypeController {
   public function on_start(){
      $this->set('pageTitle', 'Homepage');
   }   
}


and this is the home.php view file at:
/applicaiton/themes/main/home.php
which is being included via the page template homepage.php at:
/applications/themes/main/homepage.php
<?php
defined('C5_EXECUTE') or die("Access Denied.");
$this->inc('elements/header.php'); ?>
<main>
<div class="container"><h1><?php echo $pageTitle; ?></h1></div>


Can anyone explian why the variable would show in the page type defaults, but not on the page itself? I have cleared the cache and turned off all caching.

 
andrew replied on at Permalink Reply
andrew
I doubt that the home page actually has the home page type applied to it. Currently, while you can change page templates you can't change page types on existing pages. So you added a page type named home and probably a home page template, and you can change the template but the home page doesn't actually come with a page type assigned to it – and you can't edit it to set it to home through the UI currently.

There are a number of technical reasons for why changing page types on existing pages is challenging, so we want to do it right. It is a bummer in this case. If you could find the ID of the page type by going into the Dashboard, hovering over the Basic Details button, and finding the number after the "/edit/" in the URL slug, you could then change it manually through the database.

update Pages set ptID = your PageTypeID where cID = 1


That would manually do it. Not 100% sure this would solve the problem but it should get you closer.
brendonohanlon replied on at Permalink Reply
Thanks Andrew,
I'll try the DB update and see if that works. I'll post a reply once done (not currently on the machine hosting that website right now).
chriisi replied on at Permalink Reply
hi there.

did u find a solution to this issue?
andrew replied on at Permalink Reply
andrew
FYI you can now change page types in 5.7, so this could be easily accomplished through the Dashboard Sitemap without having to run a direct database query.
brendonohanlon replied on at Permalink Reply
Thanks Andrew,
I did try the DB update you suggested, and it did work to some extent but needed some other manual changes that I can't recall offhand. I will update my installation to the newest version then follow your most recent example. Apologies for the delayed reply Andrew and Chris, I haven't been online in a few weeks.