Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable Plone 5 Toolbar for authenticated user group?

Scenario below:

  • A user logs into my Plone 5 site.
  • The toolbar shows up but they have no options to do anything with it because they are in the Authenticated Group.

They only get Authenticated access to view a few areas. How can I suppress the toolbar for certain user groups? or what is the best approach to this?

like image 620
hietpasd Avatar asked Dec 11 '22 20:12

hietpasd


2 Answers

The simplest approach will be using CSS. You can provide a conditional CSS that hide the toolbar:

#plone-toolbar-container {display: none}

A very simple approach for this is described in this article: http://datakurre.pandala.org/2015/05/plonecustom-for-plone-5.html

Please note: the toolbar contains also a section to personal preference, so removing it will also hide some user's features.

like image 89
keul Avatar answered Jun 14 '23 01:06

keul


A nice way is to use roles and permissions. You can hide the toolbar for the Member role only (and not Editor, Reviewer and Manager) by overriding the toolbar and defining your own condition that filters on the ModifyPortalContent permission.

Here is an example for when you are developing your own Add on that depends on z3c.jbot.

  1. Put a copy of the toolbar.pt template in the overrides directory of your Add on. This is the path to the template: plone/app/layout/viewlets/toolbar.pt. Rename the new file to plone.app.layout.viewlets.toolbar.pt for it to work (see plone docs).

  2. Customise the main condition in the template.

    <section id="edit-bar" role="toolbar"
     tal:define="portal_state view/portal_state;
                 personal_bar python: view.get_personal_bar()"
     tal:condition="not: portal_state/anonymous"
     i18n:domain="plone">
    

    becomes

    <section id="edit-bar" role="toolbar"
     tal:define="portal_state view/portal_state;
                 personal_bar python: view.get_personal_bar();
                 checkPermission nocall: context/portal_membership/checkPermission"
     tal:condition="python:checkPermission('Modify portal content',context)"
     i18n:domain="plone">
    
  3. Add some CSS to remove the padding on the body for the Member role only.

    userrole-member.plone-toolbar-left-default { padding-left:0 }
    

Now supply some new links for the user to /@@personal-preferences and /logout and you're done.

like image 40
Johannes Avatar answered Jun 14 '23 01:06

Johannes