Single Pages from Package

Permalink
Hello! I am trying to add a single page from a package, but it does not appear to be loading the view.php template from the theme. It installs the page just fine but when I go the the page the code does not match the view.php template from the theme. Also, when I go to the sitemap page in the dashboard and click on the new Profile page and select "Design & Type", it does not show the "This is a single page..." warning on the Page Template and Page Type drop down. It will actually allow me to select a page template and type. So I think that Concrete5 doesn't see it as a single page.

Does anyone know why this might be?

In my package controller, I have this:
(packages/my_package/controller.php)
<?php
namespace Concrete\Package\MyPackage;
use Package;
use \Concrete\Core\Page as Page;
use \Concrete\Core\Page\Single as SinglePage;
class Controller extends Package
{
   protected $pkgHandle = 'my_package';
   public function install()
   {
       $pkg = parent::install();
       $path = '/profile';
           $page = Page::getByPath($path);
           if (!is_object($page) || $page->isError()) {
               SinglePage::add($path, $pkg);


In my single page controller, I have this:
(packages/my_package/controllers/single_page/profile.php)
<?php
namespace Concrete\Package\MyPackage\Controller\SinglePage;
defined('C5_EXECUTE') or die(_("Access Denied."));
use Concrete\Core\Page\Controller\PageController;
use Concrete\Core\View\View;
use Concrete\Core\Page\Page;
class Profile extends PageController {
   public function view() 
   {
      $this->set('test','The profile controller is connected');
   }
}


In the single page view, I have this:
(packages/my_package/single_page/profile.php)
<?php defined('C5_EXECUTE') or die("Access Denied."); ?>
<div class="profile-page">
  <div class="container">
    <h2><?php echo $c->getCollectionName(); ?></h2>
    <?php echo 'controller test: '.$test; ?>
  </div>
</div>


I have a class in the view.php file in the theme that I am looking for, but it is not in the code, nor does anything from the view output to the screen. I have even tried adding a die() statement in both the controller and the view, but it doesn't affect the rendered output. If I uninstall the package and then move the controller and the view out of the package and into the Application folder and adjust the namespace properly. I can install them through the Single Page dashboard page and they work correctly.

Any help would be greatly appreciated!

ScottSandbakken
 
linuxoid replied on at Permalink Best Answer Reply
linuxoid
Please note the view file must be in packages/my_package/single_pages/profile.php - see the 'single_pages' is plural! While the controller is in 'single_page' singular.

Please also have a look at that thread - pay attention to the file, folder, class and namespace names:

https://www.concrete5.org/community/forums/customizing_c5/help-with-...

And have a look at the skeleton package I've created, see how it's all done there:

https://www.concrete5.org/community/forums/customizing_c5/free-concr...
ScottSandbakken replied on at Permalink Reply
ScottSandbakken
linuxoid,

Thank you so much! I spent way too much time trying to figure this out. Looks like I just missed the "s" to make single_pages plural like you said.

Thanks again!