I need to create signle global configuration page without list view, just single page with number of inputs like:
- fb page link
- google analytics id
- some default front-end texts
- checkbox options: show intro, show social media etc.
something that doesn't require to go through record listing, edit, save and return to list etc.
Do i need to create new controller with form and my own crud? Or is there a way to nicely connect/override sonata admin with that kind of panel?
I'm using:
- Symfony 2.3.X Latest
- Sonata cache 2.1.5
- Sonata block 2.2.7
- Sonata easy-extends 2.1.4
- Sonata admin 2.2.8
- Sonata doctrine-orm-admin 2.2.5
- Sonata jquery 1.8.*@dev
- Sonata intl 2.2.*@dev
- Sonata user 2.2.*@dev
- Sonata media 2.2.*@dev
- Sonata page 2.3.*@dev
- Sonata seo 1.1.*@dev
- Stof Doctrine Extensions Latest
EDIT
Following answer of pulzarraider and some more search i ended up with overriding listAction of CRUD controller.
In details, first created service definition (YML):
services:
stack.admin.global_administration:
class: Stack\Bundle\SiteBundle\Admin\GlobalConfigurationAdmin
tags:
- name: sonata.admin
manager_type: orm
group: Administration
label: Global Configuration
arguments:
- ~
- ~
- StackSiteBundle:GlobalConfiguration
Then created Admin class for this specific action:
<?php
namespace stack\Bundle\SiteBundle\Admin;
use Sonata\AdminBundle\Admin\Admin;
use Sonata\AdminBundle\Route\RouteCollection;
class GlobalConfigurationAdmin extends Admin
{
protected $baseRouteName = 'global-configuration';
protected $baseRoutePattern = 'global-admin';
protected function configureRoutes(RouteCollection $collection)
{
// notice removal of create action!
$collection->remove('create');
}
}
?>
And finally CRUD controller to display custom form instead of default entity list action:
<?php
namespace Stack\Bundle\SiteBundle\Controller;
use Sonata\AdminBundle\Controller\CRUDController as Controller;
use Symfony\Component\HttpFoundation\Request;
class GlobalConfigurationController extends Controller
{
public function listAction()
{
if (false === $this->admin->isGranted('LIST')) {
throw new AccessDeniedException();
}
// custom code here...
return $this->render('StackSiteBundle:Administration:configuration-view.html.twig', array(
'action' => 'list',
'csrf_token' => $this->getCsrfToken('sonata.batch')
));
}
}
?>
Thanks for help with this one!
StackSiteBundle:Administration:configuration-view.html.twig? - SlimenTN