You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In order to learn Fat-Free-Framework, I decided to start tweaking Fabulog to add support for Pages (I can share my code when I am done)
Here is what I did:
1 ) Created a new model "Page", new Admin views "page-list.html", "page_edit.html", "page_layout.html", and a new controller "Page". Obviously, these are tweaked copies of your Post versions.
2 ) I added the Page section in the admin menu
3 ) I changed the routing at follows:
// view list
$f3->route(array(
'GET /',
'GET /page/@page'
),'Controller\Post->getList');
// view single
// pages have priority: if the slug isn't found in page, we will call Post->getsingle
$f3->route(array(
'GET /@slug',
'GET /p/@slug',
), 'Controller\Page->getSingle');
$f3->route(array(
'GET /post/@id'
), 'Controller\Post->getSingle');
4 ) In my page not found handling, I added this:
if ($this->resource->dry()){
if (!isset($params['id'])) {
$postcontroller= new Post();
$postcontroller->getSingle($f3, $params);
/*
$f3->route(array(
'GET /'. $params['slug'],
), 'Controller\Page->getSingle');
*/
}
else{
$f3->error(404, 'Page not found');
}
}
The problem may be that you are getting the post but not actually assigning any of the post data to anything that will be rendered in the view.
Take a look at these lines
`
// copy whole page model, to be able to fetch relations
// on the fly from within the template, if we need them
$this->response->data['page']=$this->resource;
$f3->set('page.title',$this->resource->title.' - '.\Config::instance()->blog_title);`
$f3->set is setting the data that will be rendered in the view.
Once you get the post you need to actually set something in the response that will be read on the front end.
In order to learn Fat-Free-Framework, I decided to start tweaking Fabulog to add support for Pages (I can share my code when I am done)
Here is what I did:
1 ) Created a new model "Page", new Admin views "page-list.html", "page_edit.html", "page_layout.html", and a new controller "Page". Obviously, these are tweaked copies of your Post versions.
2 ) I added the Page section in the admin menu
3 ) I changed the routing at follows:
4 ) In my page not found handling, I added this:
But neither methods work...
I instead get a page without the post loaded.
I can simply redirect to /post/@slug
But I was hoping to avoid doing that...
Do you have any ideas?
Here are my thoughts:
1 ) I do not yet fully understand the resource, so it's quite possible that the resource is still trying to work with pages.
2 ) Perhaps it's not possible to route or call a new controller from within a controller without extra initialization?
The text was updated successfully, but these errors were encountered: