
How to Create and Use an eZ Publish Website Toolbar Extension
One of the frequently asked questions by Website Interface users is ?how can I use the Website Toolbar in my own project?? Many people have experienced the usefulness of the Website Toolbar (which is a handy toolbar with editing operations built into the front-end of an eZ Publish site), but already have an existing site and thus do not want to modify the ?ezwebin? package design. I will explain how to build an ?ezwebsitetoolbar? extension that can be used in existing projects.
To do so, you will need to copy files from an eZ Publish 3.9 installation with the Website Interface 1.2-0 or higher, then edit a few files. You can then copy the new extension to your existing eZ Publish installation and make use of it.
Building the extension
Copying files from the Website Interface extension
First, we have to copy the Website Toolbar files from the Website Interface extension folder, which is located in extension/ezwebin under your eZ Publish root directory.
Make a new folder extension/ezwebsitetoolbar for the destination of the copy. Note that you will have to create all the subdirectories under the ezwebsitetoolbar directory in the following copy operations.
Copy:
extension/ezwebin/autoloads/ezcreateclasslistgroups.php extension/ezwebin/autoloads/eztemplateautoload.php
to
extension/ezwebsitetoolbar/autoloads
Edit eztemplateautoload.php and leave the following content:
<?php $eZTemplateOperatorArray = array(); $eZTemplateOperatorArray[] = array( 'script' => 'extension/ezwebsitetoolbar/autoloads/ezcreateclasslistgroups.php', 'class' => 'eZCreateClassListGroups', 'operator_names' => array( 'ezcreateclasslistgroups' ) ); ?>
Then, copy all images from:
extension/ezwebin/design/ezwebin/images/websitetoolbar
to
extension/ezwebsitetoolbar/design/standard/images/websitetoolbar
Then, copy:
extension/ezwebin/design/ezwebin/stylesheets/websitetoolbar.css
to
extension/ezwebsitetoolbar/design/standard/stylesheets
Copy:
extension/ezwebin/design/ezwebin/templates/parts/website_toolbar.tpl extension/ezwebin/design/ezwebin/templates/parts/website_toolbar_edit.tpl extension/ezwebin/design/ezwebin/templates/parts/website_toolbar_versionview.tpl
to
extension/ezwebsitetoolbar/design/standard/templates/parts
Copy:
extension/ezwebin/modules/websitetoolbar
to
extension/ezwebsitetoolbar/modules/websitetoolbar
Note: The modules folder does not exist in Website Interface versions lower than 1.2-1. If you are using an earlier version, the ?ezwebsitetoolbar? extension will still work, but you will not be able to use the built-in eZ Publish permissions feature to manage the Website Toolbar. I will explain this further at the end of this post.
Copy:
extension/ezwebin/settings/design.ini.append.php extension/ezwebin/settings/module.ini.append.php extension/ezwebin/settings/site.ini.append.php extension/ezwebin/settings/websitetoolbar.ini
to
extension/ezwebsitetoolbar/settings
Editing the configuration files
Next, update the configuration files in the extension/ezwebsitetoolbar/settings folder.
In extension/ezwebsitetoolbar/settings/design.ini.append.php put:
<?php /* [ExtensionSettings] DesignExtensions[]=ezwebsitetoolbar */ ?>
In extension/ezwebsitetoolbar/settings/module.ini.append.php put:
<?php /* [ModuleSettings] ExtensionRepositories[]=ezwebsitetoolbar */ ?>
In extension/ezwebsitetoolbar/settings/site.ini.append.php put:
<?php /* [TemplateSettings] ExtensionAutoloadPath[]=ezwebsitetoolbar */ ?>
Installation
Now you can copy the ?ezwebsitetoolbar? extension to your existing eZ Publish installation, then enable it in the Administration Interface (in the Extensions menu under the Setup tab).
Next, insert the following lines into your pagelayout.tpl file:
<style type="text/css">
@import url({"stylesheets/websitetoolbar.css"|ezdesign});
</style> {include uri='design:parts/website_toolbar.tpl' current_node_id=$module_result.node_id}
In content/edit.tpl or its override file, include:
{include uri='design:parts/website_toolbar_edit.tpl'}
In content/view/versionview.tpl or its override file, include:
{include uri='design:parts/website_toolbar_versionview.tpl'}
If you used the Website Interface 1.2-1 or higher to generate the ?ezwebsitetoolbar? extension, you can use the built-in eZ Publish permission system to manage the Website Toolbar. To do so, add a policy to the ?websitetoolbar? module to the appropriate roles in the Roles and Policies menu under the User accounts tab in the Administration Interface. Otherwise, you will have to make sure the User group content class (in the Classes menu under the Setup tab in the Administration Interface) has a checkbox attribute with the identifier ?website_toolbar_access?, then edit the relevant User group objects and mark that checkbox.
Finally, clear all the caches (under the Cache window on the right of the Administration Interface) and you should now be able to use the Website Toolbar in your existing eZ Publish project. Of course, you will need to configure it a bit more (see extension/ezwebsitetoolbar/settings/websitetoolbar.ini).
This tutorial has explained how to extract the Website Toolbar from the Website Interface. You can find the latest version of the Website Toolbar extension in the eZ Publish contribution section.

Comments

Great
Very useful article. I will test it right today...

Content modified doesn't appear
Hi,
thanks for this article. I have only a problem : when i edit an object into the front-end and publish it, the new content doesnt't appears immediatly. Two methods to view it : in the admin interface, edit the object and publish it or clear the cache. :-( An idea to resolve this problem ? ...
thanks
Sébastien

A little tip
Thanks for sharing, it's very useful and easy to install.
To give to the editor a better experience (see the published content
instead of the parent) after edit you could add to content/edit.tpl
{def $redirect_pub=ezhttp('LastAccessesURI','session')}
{def $redirect_dis=ezhttp('LastAccessesURI','session')}
<input type="hidden" name="RedirectURI" value={$redirect_pub} />
<input type="hidden" name="RedirectURIAfterPublish" value={$redirect_pub} />
<input type="hidden" name="RedirectIfDiscarded" value={$redirect_dis} />
{undef $redirect_pub $redirect_dis}
I was unable to find out a simple way to redirect to the new created content
since the object does't know the node_id (maybe because it will be
assigned later) and the LastAccessesURI has the value of the parent.






re using ezwebin instead of forking it
Wednesday 18 February 2009 12:50:04 pm
André R.
It's possible to just download the ezwebin extenion and include the files you need as written directly from that as well. So there is less work when you want to update it later (and the above solution will need additional files when you want to merge the sort button in webin 1.4).
But you will need to add ezwebin as a design for your site to make this work, so you'll need to go over you site afterwards and look for places where you just reused standard templates but now get webin templates, and see if it breaks anything(css).
LS: maybe move the toolbar stuff to standard design in ezwebin? (but make sure it does not conflict with any thing so it suddenly shows up in admin and so on).