Single Page Controller in package not recognized

Permalink 1 user found helpful
Hi everybody!
I've got a little problem with single pages in a package. It is no problem to install the single page. And it is possible to browse to the page.
But the controller is not recognized by concrete5.

My environment:
Package XYZ (Folder)
-- single_pages (Folder)
---- newsletter (Folder)
------ view.php (File)
-- controller (Folder)
---- single_pages (Folder)
------newsletter.php (File for controller)

controller.php
namespace Concrete\Package\NakNewsletterPackage\Controller\SinglePage;
defined('C5_EXECUTE') or die('Access Denied.');
use Concrete\Core\Page\Controller\PageController;
use DB;
use Loader;
class Newsletter extends PageController
{       
   public function view()
   {            
      $this->set('initValue','1');
   }


view.php
<?php
defined('C5_EXECUTE') or die('Access Denied.');
echo ($initValue);


The installation is done via an install.xml-file.

View Replies:
rge replied on at Permalink Reply
The folder should be controller/single_page
Note without the "S".

When I create a single page I install it via the package controller like this
public function install()
{
   $pkg = Parent::install();
   //Install single pages
   SinglePage::add('/mypage/', $pkg);
}


You can find the documentation here:
https://www.concrete5.org/documentation/developers/5.7/working-with-...
cko77 replied on at Permalink Reply 1 Attachment
So, it took a long time but I was able now to try your suggestion. But without any success.

Please find a structure of my package directory.

controller.php (nak_newsletter)
<?php
namespace Concrete\Package\NakNewsletter;
use Package;
defined('C5_EXECUTE') or die('Access Denied.');
class Controller extends Package 
{
    protected $pkgHandle = 'nak_newsletter';
    protected $appVersionRequired = '5.7.1';
    protected $pkgVersion = '0.0.1';
    public function getPackageName() 
    {
        return t("NAK Newsletter");
    }
    public function getPackageDescription() 
    {


newsletter.php (nak_newsletter/controller/single_page/)
<?php
namespace Concrete\Package\NakNewsletter\Controller\SinglePage;
defined('C5_EXECUTE') or die('Access Denied.');
use Concrete\Core\Page\Controller\PageController;
class Newsletter extends PageController
{
    public function on_start()
    {
    }
    public function on_before_render()
    {
    }
   public function view()
      {
      $this->set('first','value');


I've got the, when installing, the following error message: "Class 'Concrete\Package\NakNewsletter\SinglePage' not found"

I do not know where my mistake is.
I've used the documentation of concrete5 as template.
I tried it with different cominations but without any positive result.
rge replied on at Permalink Reply
nak_newsletter/controller/single_page/ should be
nak_newsletter/controllers/single_page/
cko77 replied on at Permalink Reply
Thanks for your reply but i does not fixed the problem. The problem is still the same.

I renamed the sub dir "controller" to "controllers". I also have taken a look into the single pages dir of the concrete dir, and in the controllers dir of the concrete dir to have a template. But it didn't helped me!
cko77 replied on at Permalink Reply
I got a positive result using a xml-file as installation resource.

After correcting my stupid "s"-mistake, the controller is recognized. The value set in the view function is called and displayed in the file that renders the content.

Many thanks for your help!!!!!!!
rge replied on at Permalink Reply
You are welcome.