This site has been archived and you can no longer log in or post new messages. For up-to-date community resources please visit ezplatform.com

eZ Community » Learn » eZ Publish » Creating Custom Admin Modules & Views

Creating Custom Admin Modules & Views

Monday 18 April 2011 11:42:34 pm

  • Currently 4 out of 5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Setting up the extension

We will create an extension to house our code in this tutorial so the code is isolated and can be easily used on multiple projects. Let’s create an extension called mynewsletter. If you call your extension something else be sure to rename all code samples which use the extension name.

This extension will store the custom views we create and also the custom module we build.

 

Activating modules within the extension

We will firstly ensure eZ Publish looks within our extension for the custom modules we create. At the same time, we also need to tell it the name of the modules which exist in our extension This offers us the potential to create multiple modules within the same extension however in our case we will just need to create one, which I have named as “newsletter”. The module name we provide here will be used in the URL whenever we are dealing with the module.

Create a file named extension/mynewsletter/settings/module.ini.append.php and add the following content:

<?php /*
 
[ModuleSettings] 
ExtensionRepositories[]=mynewsletter
ModuleList[]=newsletter
 
*/ ?>
 

There are a couple of lines of code here and each are equally important.

  • The ExtensionRepositories[] setting provides an array of all extensions which contain modules. If you want to see which other extensions contain modules go to the Setup tab within the admin siteaccess and click on the “Ini settings” link within the left hand column. Once the two dropdowns appear, select module.ini.append.php and your siteaccess and you should see a complete list (this can be useful for the other settings files if you are unsure why a certain setting is being used over a different one).
  • The ModuleList[] ensures we can find the specific modules within this extension (this will be explained further when we create our first module). Multiple Modules can be created within a single extension by duplicating this line for each module you create.
 

Activating template files within our extension

To ensure the templates we create in our extension (as well as any specific CSS or images you are storing in the extension ) are retrieved we need to ensure the design folder is included when templates are searched for. We do this by creating another settings file in the settings directory called design.ini.append.php (extension/mynewsletter/settings/design.ini.append.php). Create the file and add the following code:

<?php /*
 
[ExtensionSettings]
DesignExtensions[]=mynewsletter
 
*/ ?>
 

Activating the extension

The final part of setting up the extension is ensuring the extension itself is active. Navigate to /settings/override from the root of your eZ Publish site. In this directory there should be a file called site.ini.append.php. If no file exists, create it now and then open it. Enter the following settings underneath the settings which already exist, if any :

<?php /* #?ini charset="iso-8859-1"?[ExtensionSettings]
ActiveExtensions[]=mynewsletter
 
*/ ?>
 

Note: If you already have an ExtensionSettings element in the file, simply add the ActiveExtensions line rather than duplicating the whole block.

Now that we have setup the extension we are ready to create our module.

 

Printable

Printer Friendly version of the full article on one page with plain styles

Author(s)

Proudly Developed with from