This is a weird problem I am facing. The Sonata admin bundle logo and the title are displayed on 2 different lines..
The following are the contents of my config file.
sonata_block:
default_contexts: [cms]
blocks:
sonata.admin.block.admin_list:
contexts: [admin]
sonata.block.service.text:
sonata.block.service.action:
sonata.block.service.rss:
sonata_admin:
title: MyTitle
Any ideas?
try your own logo
sonata_admin:
title: MyTitle
title_logo: /bundles/yourbundle/images/logo.png
Related
Following this example: https://learn.getgrav.org/forms/blueprints/example-page-blueprint
I created my video.yaml file under "user/themes/MYTHEMENAME/blueprints", contents of its file:
title: Gallery
'#extends':
type: default
context: blueprints://pages
form:
fields:
tabs:
type: tabs
active: 1
fields:
gallery:
type: tab
title: Gallery
fields:
header.txf:
type: text
label: Add a number
default: 5
validate:
required: true
type: int
header.sb:
type: select
label: Select one of the following
default: one
options:
one: One
two: Two
three: Three
Cleared all caches, but i still don't see that tab under "/admin/pages" or "/admin/pages/home" advanced tab. What's wrong? Is it bug?
UPDATED INFO
"user/themes/MYTHEMENAME/MYTHEMENAME.yaml":
enabled: true
dropdown:
enabled: true
"user/config/site.yaml":
title: domain.org
author:
name: Name
email: 'email#mail.com'
metadata:
description: 'analytical news feed'
generator:
Tried to put them under "user/blueprints/pages/" - still not EFFECT! Why such an easy tasks is too complicated in grav...
Your blueprint is correct, it works on my side.
You said you don't see that tab under "/admin/pages" or "/admin/pages/home". This is not how a blueprint works, blueprint is only available for its page template. You didn't mention any sample paths of your page so it seems your page use a different template.
If your blueprint is user/themes/yourtheme/blueprints/video.yaml, it is only available for the pages which use video template, for example user/pages/home/video.md. Your blueprint will not available to all pages on the site.
Similar to modular template, you need to put your blueprint in modular folder: user/themes/yourtheme/blueprints/modular/video.yaml, and your modular page needs to use that template as well user/pages/home/_myvideo/video.md
I am having a weird situation which has halted my progress for the second day now and I am almost going bald from pulling my hair on this. I have a custom block on the sonata admin dashboard which is not being found when I try to load the page.
I have gone over the configuration a couple of times and maybe I am missing something which an extra pair of eyes may be able to spot which is why I am posting this question here.
I have built my block as below and saved it under src\AppBundle\Block\NumbersBlockService.php
namespace AppBundle\Block;
use Symfony\Component\HttpFoundation\Response;
use Sonata\AdminBundle\Form\FormMapper;
use Sonata\AdminBundle\Validator\ErrorElement;
use Sonata\BlockBundle\Model\BlockInterface;
use Sonata\BlockBundle\Block\BaseBlockService;
use Sonata\BlockBundle\Block\BlockContextInterface;
use Doctrine\ORM\Query\ResultSetMapping;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use DoctrineExtensions\Query\Mysql;
class NumbersBlockService extends BaseBlockService
{
......
}
Then defined my service in the service.yml file as below:
sonata.block.service.topnumbers:
class: AppBundle\Block\NumbersBlockService
arguments:
- sonata.block.service.topnumbers
- "#templating"
- "#doctrine.orm.entity_manager"
- "#security.token_storage"
tags:
- { name: sonata.block }
My config.yml file includes the block like this
sonata_block:
default_contexts: [cms]
blocks:
sonata.user.block.menu: # used to display the menu in profile pages
sonata.user.block.account: # used to display menu option (login option)
sonata.block.service.text: # used to if you plan to use Sonata user routes
sonata.block.service.topnumbers:
and finally, I position the block on top with the line below
sonata_admin:
dashboard:
blocks:
- { position: top, type: sonata.block.service.topnumbers, class: col-md-12}
I have checked the tutorial on creating a custom block here https://sonata-project.org/bundles/block/master/doc/reference/your_first_block.html and everything seems to check out but I still get the following error below:
An exception has been thrown during the rendering of a template ("The block type "sonata.block.service.topnumbers" does not exist") in SonataAdminBundle:Core:dashboard.html.twig at line 60.
Someone please help put me out of my misery. Thanks in advance
I'm working on a web project using Symfony2 , and i used Sonata Admin for the admin Panel , every thing works fine but what i want to do is ,on the dashboard menus of sonata Admin , i need to show hide some menus depend on the admin ROLE , so did any one do this before or know how to do it ?
i tryed to use the config of the roles but when i'm connecting with a ROlE diffrent of ROLE_SONATA_ADMIN the top menu dont show up ,
- { path: ^/admin, role: [ROLE_ADMIN, ROLE_SONATA_ADMIN,ROLE_ADMIN_NEWS] }
thanks
i found the solution for this i need just to define the groups on the config.yml Like this
dashboard:
groups:
Content:
label: Content
items:
- sonata.admin.pages
- sonata.admin.menus
roles: [ ROLE_ADMIN_CONTENT, ROLE_SUPER_ADMIN ]
I'd like to render the links to user management and ACL editing on my SonataAdmin Dashboard. What do I need to add to sonata_block section? Also, what are these 'cms' and 'admin' contexts?
sonata_block:
default_contexts: [cms]
blocks:
# Enable the SonataAdminBundle block
sonata.admin.block.admin_list:
contexts: [admin]
# Your other blocks
sonata.user.block.menu: ~ # used to display the menu in profile pages
sonata.user.block.account: ~ # used to display menu option (login option)
sonata.block.service.text: ~
sonata.block.service.rss: ~
sonata.block.service.imagesize:
contexts: [admin]
groups:
admin.group.content:
label: My Label
label_catalogue: SonataAdminBundle
items:
- sonata.admin.????
Please note, the cms context will be renamed into sonata_page_bundle to be more appropriate.
Each block can be defined in a specific context (ie, an admin related block does not need to be added as a cms block).
So if we set a context to a block, the default value will not be applied and so the block will be not listed in the SonataPageBundle or any other bundles using this context.
Now, if you want to add content into the dashboard, you have some options:
- overwrite the dashboard template so you can fine tune the overall layout and add link to the user management.
- create a block and add it to the block configuration of the sonata_admin section.
You can create a new block by following the BlockBundle tutorial available at: http://sonata-project.org/bundles/block/master/doc/reference/your_first_block.html
I'm trying to customize my dashboard of Sonata but although I can change the layout, I can't make the controller to be the one I want (and with that pass some other values). So sonata always loads the default on the CoreController and not the one that I want. Can you tell me what I have to do for changing the controller for the one I want?
This is a part of my config.yml:
sonata_admin:
title_logo: bundles/ebuigui/images/brand.png
templates:
dashboard: EBUIBackendBundle:CRUD:adminView.html.twig
list: EBUIBackendBundle:CRUD:list.html.twig
edit: EBUIBackendBundle:CRUD:create.html.twig
dashboard:
blocks:
# display a dashboard block
- { position: left, type: sonata.admin.block.admin_list }
sonata_block:
default_contexts: [cms]
blocks:
# Enable the SonataAdminBundle block
sonata.admin.block.admin_list:
contexts: [admin]
it's better that you use eventListener to modif the logic of Sonata CoreController. If you want to override the core controller you can reffer to a question asked before