Developer's Guide

  • Docs Home
  • Community Home

2. Customizing the Navigation Bar

Note

This information is presented here because many people want to be able to customize the navigation bar. However, there are two possible issues with modifying this ZPT page:

  • It is possible that an upgrade or other operation will remove your modifications, so you will need to perform them again. Saving the ZPT page in a ZenPack will allow you to save your changes, but you will need to manage this ZenPack yourself.

  • Zenoss may in the future completely change this code, and there will be no effort on Zenoss' part to ensure that your changes are preserved.

Go to your Zenoss server with the following URL:

http://yourzenossserver:8080/zport/portal_skins/zenmodel/manage

2.1. Adding a link

Look for a file called leftPane. Click on the file and it will bring you to a screen which will show you the source for the file. Click on the Customize button which will copy it to the http://yourzenossserver:8080/zport/portal_skins/custom folder and open up the file. Make whatever changes you wish and then save the file. The save button is down at the bottom of the page.

Zope looks for the customized version of Web pages in the custom folder first, before any other pages of the same name.

2.2. A Simple HTML Page

If all you need is a simple Web page, go to the ZMI and add the page:

http://yourzenossserver:8080/zport/portal_skins/custom/manage

This will bring you into the ZMI starting in the portal_skins folder. From here, beside the Add button (which is near the top right-hand side of the screen), select Page Template and then click on the Add button.

In the dialog screen that comes up, give your new page a name in the Id input box. We'll use helloWorld as the name of our fist page. Then click on the Add and Edit button.

This should bring us to a text-editor web page. Delete everything that's in there and add the following:

<html>
<head>
<title>Hello World</title>
</head>
<body>
<h1>Hello world!</h1>
<p>My test page</p>
</body>
</html>

Click on the Save Changes button. Now try out our sample Web page.

http://yourzenossserver:8080/zport/helloWorld

This is just a plain old web page, with nothing fancy about it. Not really anything much to see here or get excited about.

But... did you notice that where we saved our file has absolutely no relation to where in the path we can reference our new page? That's a Zope thing. Since our page doesn't use any Zope features, we can put it anywhere. If we were to use some of Zope's TAL we might need to be more concerned. The next section will illustrate this behaviour.

2.3. A Simple TAL and METAL page

Using the same steps from the previous section, create a new Page Template called helloWorld2, which is the new and improved (okay, maybe just different :) version of your first page. Add in the following:

<tal:block metal:use-macro="here/templates/macros/page1">

<tal:block metal:fill-slot="contentPane">

<h1>Hello world!</h1>
<p>My test page</p>
</tal:block>
</tal:block>

The /zport/portal_skins/zenmodel/templates file contains the METAL definitions used by Zenoss pages. One of the page1, page2, or page3 macros will probably be a good start for what you want. Look through the templates page to see how it's built. Our example above uses the page1 macro.

After you've saved the page, you can try it out:

http://yourzenossserver:8080/zport/dmd/helloWorld2

Now you can see your page within all of the Zenoss page elements. There's a navigation bar, the logo, the server time, search bar and everything else. Now try the following URL:

http://yourzenossserver:8080/zport/dmd/Devices/helloWorld2

Now the breadcrumb path showing that you are in the Devices part of Zenoss shows up. What happens now if you go to the base of Zenoss?

http://yourzenossserver:8080/zport/hello/World2

Oops! That didn't look good, you've got an error screen. If you look in the View Error Details part, you'll notice that it's complaining about missing here/breadCrumbs. That's because the breadCrumbs function isn't on every object, just some of them.

From this point forward is a matter of examining other pages, seeing where they run from and trying out new things. The functions that Zenoss provides are written in Python, so you'll need to learn more Python in order to take advantage of Zope. See the Section 4, “Zope 2 Page Templates, TAL and METAL and Zenoss” section for more details.