How do I use 'is_toolbar_visible'

Lets say one wants to hide the toolbar for (Members) for those sections where they have no 'edit' rights:

Can this now be done without customizing the theme (CSS) ?

it's much easier with CSS than anything else since the role is included in the HTML as a CSS class

I managed to do this just by editing the rolemap for the Show toolbar permission. See Summary at:

1 Like

Checkout the latest changes in master plone.app.layout https://github.com/plone/plone.app.layout/pull/129

Thanks to work by @agitator at Midsummer Sprint, there's now a permission for that.

Great, thanks....

Does this also take care of the 'left (or top) margin' from the (default) CSS ?
... and is the right approach to use this permission in rules.xml ?

Here's the documentation https://github.com/plone/documentation/blob/5.1/develop/plone/functionality/toolbar.rst

If the toolbar is configured to NOT show, there will be NO additional class on the body tag.

are this changes going to be available in Plone 5.1b5?

I was trying to test this feature in current Plone 5.1b4 but the permission is still not there.

yes, those changes are already merged with master

I paste this in case someone needs it:

.viewpermission-none.plone-toolbar-left #edit-zone,
.userrole-reader.plone-toolbar-left #edit-zone  {
  display: none;
}
 
.viewpermission-none.plone-toolbar-left,
.userrole-reader.plone-toolbar-left{
    padding-left: 0;
}

@espenmn relying on the roles is an error prone way of doing this. Because it depends if someone has been explicitly given that role or not. For example someone might only have authenticated and member roles but not the reader role. However every other user might also have authenticated and member so it doesn't work to differentiate them.
Checking actual permissions a user has is the only full proof way but there isn't a body tag for that. The body tag for permission that is shown is the permission required by the object to view this particular view.

The best replacement I'd suggest is looking inside the html of the toolbar itself and seeing if the contents menu item is there and only showing the toolbar if it is. Not great but I can't think of a better hack for <5.1. ie diazo if you have the toolbar but without .contentview-folderContents then drop the toolbar?

To show the toolbar only to Reviewers, Site Administrators and Managers, add a rolemap.xml like this to your profile:

<?xml version="1.0"?>
<rolemap>
 <permissions>
   <permission
        acquire="False"
        name="Show Toolbar">
      <role name="Reviewer" />
      <role name="Site Administrator" />
      <role name="Manager" />
    </permission>
  </permissions>
</rolemap>

To me, it looks like some JS required (related to Change State Viewlet - #6 by espenmn ) is missing if the toolbar is disabled.
IS that possible? (I dont have access to server before a few days due to a 'dead laptop')

Doubt that... JS resources normally aren't bound to that permission.

Plone Foundation Code of Conduct