Symfony2, Sonata : Remove an action from menu generated by a sonata bundle - symfony

I need to clean the admin side so it fits to the need of my client.
I'm using NewsBundle from Sonata, i actually don't need to use comments so i'd like to remove it from the admin side. At least from the menu. Is there a way to disable it in the config? I have not find any hints in the doc about this.
Here the specific area where i would like to not see it anymore :
By the way, the menu might be generated by KnpMenu

To customize the groups shown in the dashsboard and side menu, you need to edit your app/config/config.yml:
sonata_admin:
dashboard:
...
groups:
sonata_blog:
label: sonata_content
label_catalogue: SonataNewsBundle
icon: '<i class="fa fa-th"></i>'
items:
# - sonata.news.admin.comment
- sonata.news.admin.post
sonata.admin.group.classification:
label: sonata_classification
label_catalogue: SonataClassificationBundle
icon: '<i class="fa fa-sitemap"></i>'
items:
- sonata.classification.admin.category
- sonata.classification.admin.tag
- sonata.classification.admin.collection
...

Related

How to Remove or overwrite sonata admin pagination?

When creating a page, pagination takes a very long time. I want to delete it or override it. Tell me who faced I want to remove these things
To remove only the Twig view (no impact on performance, it's just visual) :
you can define a custom Pager using this :
# app/config/your_sonata_services_config.yml
services:
app.admin.post:
class: AppBundle\Admin\PostAdmin
tags:
- { name: sonata.admin, manager_type: orm, group: "Content", label: "Post", pager_type: "simple" }
arguments:
- ~
- AppBundle\Entity\Post
- ~
public: true
With tag pager_type: simple, the view SonataAdminBundle:Pager:simple_pager_results.html.twig will be called.
source : https://symfony.com/doc/master/bundles/SonataAdminBundle/cookbook/recipe_improve_performance_large_datasets.html
To disable COUNT(*) of rows and improve performance :
You can have a look here https://github.com/sonata-project/SonataDoctrineORMAdminBundle/issues/297, you have to :
extend the default SonataPager with your own class that overrides computeNbResult()
extends the default SonataProxyQuery with your own class that overrides getFixedQueryBuilder()
extend the default SonataDatagridBuilder with your own class that overrides getBaseDatagrid()
Reference those in your services

drupal 8 field ui entity tabs not working

i defined custom entity and defined field_ui_base_route in annotation to activate field ui .
the problem is the field ui tabs don't appear on base route page but only after visiting them manually in address bar .
field_ui_base_route is portal_admin.office_overview
portal_admin.office_overview:
path: '/admin/portal/org/office'
defaults:
_title: 'Portal organization'
_entity_list: 'portal_office'
requirements:
_permission: 'administer portal'
in links.task.yml i have default task :
portal_admin.office_overview:
route_name: portal_admin.office_overview
title: Overview
base_route: portal_admin.office_overview
when i manually visit /admin/portal/org/office/fields i do see all tabs .
but when clicking main tab Overview the tabs don't appear .
strangely when i do striped down example not related to entities and field ui the tabs do work :
mod1.page5:
title: 'Main'
route_name: mod1.page5
base_route: mod1.page5
mod1.page51:
title: 'sub1'
route_name: mod1.page51
base_route: mod1.page5
mod1.page52:
title: 'sub2'
route_name: mod1.page52
base_route: mod1.page5
problem fixed .
i defined the entity routes to be generated automatically using AdminHtmlRouteProvider
but also defined the path for entity.portal_office.collection manually as route portal_admin.office_overview
so this is why the route portal_admin.office_overview has local task while the route entity.portal_office.collection did not and the tabs did not appear because the route entity.portal_office.collection prevailed over portal_admin.office_overview .

Change left menu labels on Sonata Admin

How can I change the labels in the left menu of my Sonata Admin installation?
I would like to change (and understand how they are generated):
The "admin" text
The "PostCategory" label (and change it to something more "WordPress-ish" :) like "Post Categories")
These labels are defined in the tags property in the service definition of your admin page, in the config file of the admin section. See documentation here.
Example in a admin-services.yml file:
services:
app.admin.category:
class: AppBundle\Admin\CategoryAdmin
tags:
- { name: sonata.admin, manager_type: orm, group: "My Admin Group", label: "Post Categories" }
arguments:
- ~
- AppBundle\Entity\Category
- ~
calls:
- [ setTranslationDomain, [AppBundle]]
The group tag corresponds to your admin label, and the label one to your PostCategory.
I guess you didn't specify these tags, and admin is the default group name, and PostCategory the name of your class.
EDIT:
The label and the group option are translation keys. You specify the translation domain under the calls tag, with setTranslationDomain, and the default catalog is messages. See documentation on translation here.

Using Netlify CMS with Hugo - creating posts with galleries

I'm new to both Hugo and Netlify, so it's possible I'm simply doing this wrong.
I've successfully built and deployed a site with galleries, using Hugo, the Galleria plugin, and deploying to Netlify This has all worked. However, I want to try using the Netlify CMS, and am struggling to set it up to handle the gallery feature (it's doing fine for just writing a text post)
I'm not sure if this is a limitation of Netlify CMS, or if I'm doing galleries in a way that isn't suited to static sites.
To implement the gallery in Hugo, I am doing the following in the front matter of each post:
+++
date = "2017-02-13T23:17:09+01:00"
summary = "In which I fail to RTFM, visit a Lamasery, and eat a lot of fruit."
tags = []
title = "China 2017: Day 11"
[[galleria]]
imgSrc = "../images/china/11/Lama-Temple.JPG"
imgTitle = "Hall In The Lama Temple"
imgDesc = "One of the main halls of the Lama Temple."
[[galleria]]
imgSrc = "../images/china/11/Octagonal-Hall.JPG"
imgTitle = "Octagonal Hall"
imgDesc = "An octagonal building just inside the entrance of the Lama Temple"
.
.
.
+++
Then in the layout page:
{{ if isset .Params "galleria" }}
<div class="galleria">
{{ range .Params.galleria}}
<img src="{{ .imgSrc }}" alt="{{ .imgTitle }}" data-title="{{ .imgTitle }}" data-description="{{ .imgDesc }}">
{{ end }}
</div>
{{ end }}
The on the Netlify CMS setup I tried adding an Object widget:
- name: "galleria"
label: "Gallery"
widget: "object"
optional: true
fields:
- {label: "Title", name: "imgTitle", widget: "string"}
- {label: "Gallery Image", name: "imgSrc", widget: "image"}
- {label: "Description", name: "imgDesc", widget: "string"}
I'm left with two problems:
(i) The object shows up, but of course only once. How would I set it up to allow me to enter as many images as I want?
(ii) On build, I'm getting an error: ERROR 2017/05/28 22:37:20 Error while rendering "page": template: _default/single.html:23:15: executing "_default/single.html" at <.imgSrc>: can't evaluate field imgSrc in type interface {}
So it seems I'm doing something wrong even trying to get one image (and associated data) in to a post.
Putting this here in case other people get stuck on this.
After asking around, and thanks to the lovely people in the Netlify Gitter channel:
I should have used a list widget, rather than an object. The YAML now looks like this:
- name: "galleria"
label: "Gallery"
widget: "list"
optional: true
fields:
- {label: "Title", name: "imgTitle", widget: "string"}
- {label: "Gallery Image", name: "imgSrc", widget: "image"}
- {label: "Description", name: "imgDesc", widget: "string"}
This has removed the build error, and provides me a widget in the CMS editor where I can add as many (or few) images as I wish.
I have now hit a follow up problem, where posts created with the CMS are created correctly, appear in the right folders in the repo, but 404 . . .

sonata and single page

i'm newbie of sonata,
i have a ContentTestAdmin with entity etc, that can only contains 4 record
- record 1
- record 2
- record 3
- record 4
i already disabled create and delete function
public function configureRoutes(RouteCollection $collection)
{
$collection->remove('create')->remove('delete');
}
but i need to change link on dashboard and on the left menu:
actually i put on my service.yml
admin.comuni:
class: AppBundle\Admin\ContentTestAdmin
arguments: [~, AppBundle\Entity\ContentTest, ~]
tags:
- { name: sonata.admin, manager_type: orm, label: Content Test, group: Main Section }
and i see on dashboard the box with title "Content" and inside the "Content Test" with link to the list
i would erase this part and see like
Content test
- record 1 title > with link to 1/edit
- record 2 title > with link to 2/edit
- record 3 title > with link to 3/edit
- record 4 title > with link to 4/edit
same issue for the left menu, a folder named Content test with 4 link inside
is possible? thank you
You should be configuring your admin menu in your app/config.yml.
Here is an example :
sonata_admin:
dashboard:
groups:
content_test:
label: Content
icon: '<i class="fa fa-address-card"></i>'
items:
- route: 'route_to_record1'
route_params: { id: 1 } #id of record 1
label: Record 1
- route: 'route_to_record_2'
route_params: { id: 2 }
label: Record 2
To find out the route to a record execute the command
app/console (bin/console on sf3) debug:router
This will show you all the routes existing in your app just find the route sonata admin generated for your ContentAdmin for show or edit or whatever you need( ex: admin_content_test_show).then just fill route_params with the id of the desired record.
(you can use that to point to any route in your app and prefill any parameters of that route)
Hope you find this helpful

Resources