Tutorial: Adding More Boxes to the Sidebar

May 09, 2005 17:39


There is a text box named "Your other information" in the customization wizard, in the "Text" tab, where you can add some custom text. You can also change the title of this text box by changing the "Other Title" property in the "Text" tab. This text is contained inside a box in the sidebar. (If you have ever used the Component style a box is the same thing as a component.)

If you want to add more than one box, you cannot use the customization wizard any more. You will have to override the lay_print_other function. If you override the function, you can add additional boxes to your sidebar.

First you will need to know the code that is needed to start a box, the code that is needed to end a box, and code for the contents of a box (where you put your own text in).

The code required to start a box looks like this:

# box header """
1"> Title
""";

You can change the 1 in the code to either 1 or 2. Depending on the number you use, the colours of the box will change. For example, the default style has alternating blue (1) and orange (2) coloured boxes in the sidebar. If you want to keep on alternating the colours of the boxes, you will have to switch between 1 and 2 as needed. Also, you can change Title to the title of your box.

The code required to end a box looks like this:

# box footer """""";

The code required for the contents of a box looks like this:

# box contents - add your custom text below """ This is some custom text. """;

Any text that you want to put inside a box (HTML is OK) must be enclosed in between """ and """;. So, putting this all together, the code needed for one box looks like this:

# box header """
1"> Title
"""; # box contents - add your custom text below """ This is some custom text. """; # box footer """""";

Now, on to the code for overriding the lay_print_other function. Create a theme layer, or use your existing theme layer if you have one. Then, paste in the following into the layer:

function Page::lay_print_other() "Prints something, lower layers can override and put whatever they want" { # box contents from the text box in the customization wizard print rehtml( $*text_other ); # box footer """"""; # box header """
1"> Title
"""; # box contents - add your custom text below """ This is some custom text. """; }

The code will print two boxes. The first box contains the text entered in the customization wizard, and the second is a new box.

If you look closely at the code you'll notice something funny. The first line inside the function prints the box contents first. Where is the code for the start of the box, you might ask? Also, at the end, there is no code for ending the text box. Again, you ask where is the code for the end of the box? The answer is that I already put in the code in another function somewhere else, so you don't need to add it in to your code. You will need to remember this. What this means is that you do not need to add the starting box code for your first box, and you do not need to add the ending box code for the last box.

For example, if you want to have three boxes, here's how the code should be laid out:

- box contents - first box
- box footer - first box

- box header - second box
- box contents - second box
- box footer - second box

- box header - third box
- box contents - third box

tutorial, theme layer

Previous post Next post
Up