I can not get my home page (page that the user sees) manageable.


#1

I created an all new project in cakephp 3, it has the complete CRUD and login page.
I have modeled all screens with bootstrap and everything is working.
My problem is the moment I went to insert the page that the user will see (Home). I do not know how to do so that the data that I register in the adminstrativo, appears in the Home. Like, I can not make my home manageable.
Can you help me???
(My first project in cakephp)


#2

Have you tried inserting the page in the router?

/config/routes.php

Router::scope('/', function (RouteBuilder $routes) {
   $routes->connect('/myhomepage', ['controller' => 'Myhomepage', 'action' => 'index']);
}

#3

If you want that page to be the default page you would write it like this:

$routes->connect('/**', ['controller' => 'Myhomepage', 'action' => 'index']);


#4

Thank you for your response. Routes are configured correctly.
even with the right routes I still can not manage the Home page.
I need it when I add, in this case, a new recipe by admin, it appears in the Main that the user sees. I can not define this.


#5

Kind of hard to tell what you are trying to do without seeing some code. What I did in my custom CMS controller is define an ID and pull from the model that particular id or in your case the last insert id by the user. So in your controller. Assuming your model name is Cms maybe you could do it like this:

 $page = $this->Cms->find()
           ->order(['id' =>'DESC'])
           ->limit(1);

Your view should then render the last inserted ID. Or you if you are trying to get the record created by that user you have to add the appropriate query to get the associated record.