You are here: Home / What do you need? / Help and documentation / Plone Info / How to change document actions in a Plone site

How to change document actions in a Plone site

by Darrell Kingsley last modified Mar 13, 2014 12:52 PM
You can change the code in the usual viewlet way, and change the items displayed and the text/link used via the ZMI

In Plone 3.3.5, document actions are below the body copy. In order to move them back up to around the title, you need to hide the default viewlet in viewlets.xml:

 <hidden manager="plone.belowcontentbody" skinname="*">
  <viewlet name="plone.abovecontenttitle.documentactions"/>

and then add it to wherever you want. In our case it's abovecontenttitle:

 <order manager="plone.abovecontenttitle" skinname="*">
  <viewlet name="plone.abovecontenttitle.documentactions"/>

Then there's the stuff in configure.xcml


and that involves copying into browser/templates which looks like the following (this is the version which uses icons if they exist instead of text, you can remove that for the text version if you prefer):

<div class="visualClear"><!-- --></div>
<div i18n:domain="plone"
    <tal:docactions tal:condition="view/actions">

    <h5 class="hiddenStructure" i18n:translate="heading_document_actions">Document Actions</h5>

    <ul tal:define="normalizeString nocall: context/@@plone/normalizeString">
    <tal:actions repeat="daction view/actions">
        <li tal:attributes="id python:'document-action-' + normalizeString(daction['id'])">
            <a href="" tal:attributes="href daction/url; title daction/description"> <img tal:condition="python: daction.get('icon')" tal:attributes="src daction/icon; alt daction/title; title daction/title"/>  <tal:action tal:condition="python: not daction.get('icon')" tal:content="daction/title"  i18n:translate="">Action name</tal:action>  </a>


    <div tal:replace="structure provider:plone.documentactions" />


and also adding the class definition to

class DocumentActionsViewlet(ViewletBase):
    def update(self):
        super(DocumentActionsViewlet, self).update()

        self.context_state = getMultiAdapter((self.context, self.request),
        plone_utils = getToolByName(self.context, 'plone_utils')
        self.getIconFor = plone_utils.getIconFor
        self.actions = self.context_state.actions().get('document_actions', None)
    index = ViewPageTemplateFile("templates/")

 Once that's done, and the server restarted, you'll have your document actions viewlet in the right place.

To change the title of your viewlets, go to the ZMI -> portal_actions -> document_actions and edit the title there. To add icons, which with the template above means that the text inks are replaced by icons, add icons to your theme, and then reference them as follows in the Icon (Expression) field using the appropriate image filenames:


That's it. All done. his page has more info: