5.7 controllers for single_pages confusion

Permalink
I can not seem to get a crontroller to work for a single_page.

I have a single page called Newsroom

/applications/single_pages/newsroom/view.php

echo "test page";
echo "[".$test."]";
$a = new Area('Main');
$a->enableGridContainer();
$a->display($c);


and i have the controller in ...
/applications/controllers/single_page/newsroom/controller.php

namespace Application\Controller\SinglePage\Newsroom;
use Controller;
print "TEST";exit;
class Newsroom extends Controller {
  public function view() {
    $this->set('test', 'works');
  }
}


for the record, I have also put the controller in

/applications/controllers/newsroom/controller.php
/concrete/controllers/newsroom/controller.php
/applications/single_pages/newsroom/controller.php


and I have tried many versions of controller.php

namespace Application\Controller\SinglePage\Newsroom;
namespace Application\SinglePage\Newsroom;
namespace Application\Controller\SinglePage\Newsroom;
use Controller;
use Page;
use Single;
use SinglePage;
class Newsroom extends Controller {
class NewsroomController extends Controller {
class Newsroom extends PageController {
class Controller extends Single {
class Controller extends Page {
many more, ad nauseam...


Can someone please share how the 57 singlepage controllers need to be to work? I followed the examples on the Migration Guide, and either I missed something or they don’t apply to single_pages

ntisithoj
 
ntisithoj replied on at Permalink Reply
ntisithoj
ok, after wrestling this aligator, here is what worked. Mainly the issues ended when I did NOT use subfolders


These threads also helped

http://www.concrete5.org/community/forums/customizing_c5/5.7-single...
http://www.concrete5.org/community/forums/5-7-discussion/single-pag...

in applications/single_pages/news.php
echo "test page<br/>";
$myFoo = $controller->getFoo();
echo "testing getFoo...".$myFoo."<br/>";
echo "testing on_start...".$view_var."<br/>";
$a = new Area('Main');
$a->enableGridContainer();
$a->display($c);


in applications/controllers/single_page/news.php

namespace Application\Controller\SinglePage;
use PageController;
class News extends PageController {
    protected $foo = "::getFoo() works";
    public function getFoo(){
        return $this->foo;
    }
    public function view() {
       $this->set('view_var', '::view() works');
    }
}



Output =

test page
testing getFoo...::getFoo() works
testing on_start...::view() works


Then, I created a new single page called “newsroom”

cp 
applications/single_pages/news.php   applications/single_pages/newsroom/view.php
cp applications/controllers/single_page/news.php  applications/controllers/single_page/newsroom/controller.php


and changed the controller as per all the lines below

class Controller extends PageController {
class Newsroom extends PageController {
class NewsroomController extends PageController {
namespace Application\Controller\SinglePage\Newsroom
namespace Application\Controller\SinglePage
class NewsroomController extends PageController {
etc, etc


and I get

Call to undefined method Concrete\Core\Page\Controller\PageController::getFoo()

And THEN….

I moved the controller to the newsroom subdir

mv applications/controllers/single_page/newsroom/controller.php  applications/single_page/newsroom/controller.php

(which obviously where it really belongs)

and when through the many iterations of possible namespaces and class names, and got the same “Call to undefined method Concrete\Core\Page\Controller\PageController::getFoo()”

So, the upshot is, in 57, I can ONLY create view in the single_pages top dir and controllers ONLY in the controllers/single_pages top dir, contrary to both documentation and c5.6 :(

This website stores cookies on your computer. These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media. To find out more about the cookies we use, see our Privacy Policy.