This is an overview of how to add or re-arrange sidebar boxes in Opal (Libra OSWD). It will override the function Page::lay_print_sidebar. This new code will be placed in a theme layer. If you already have a theme layer, you will need to edit it and add the code below. If you do not have a theme layer, you will need to create one by following the instructions in the Theme Layer tutorial.
Adding sidebar boxes
To add a box to the bottom of the sidebar you will need to insert the following code into your theme layer, making sure to copy everything:
function Page::lay_print_sidebar { var string header; var string text; $this->lay_print_summary(); $this->print_linklist(); $this->lay_print_freetext(); $this->lay_print_calendar();$header = "Your Header"; $text = """ <div class="columnitem"> Your text/HTML here </div> """; print_box($header, $text);}
Change "Your Header" to whatever you wish your header to be. Add the contents of your sidebar box in the indicated place. Note that the text will not be auto-formatted, so you will need to format it with HTML.
You can add as many new boxes as you wish by repeating the code highlighted in orange.
Displaying sidebar boxes on certain view types
The sidebar boxes will normally appear on all the views of your journal. However, if you wish the sidebar to have different boxes depending on the page type or if you simply don't wish to clutter other pages, you can select where you would like the sidebar box to appear. You can choose one of the following view types: recent, friends, archive, month, day, entry, reply. For the explanations of what each view is, please see the overview of S2 View Types.
The following code adds a sidebar box to display only on your Recent entries page. Again make sure to copy everything. Replace recent
with one of the view types listed above if you wish it to display on a different view type.
function Page::lay_print_sidebar { var string header; var string text; $this->lay_print_summary(); $this->print_linklist(); $this->lay_print_freetext(); $this->lay_print_calendar();if ($this.view == "recent") { $header = "Your Header"; $text = """ <div class="columnitem"> Your text/HTML here </div> """; print_box($header, $text);} }
Re-arranging sidebar boxes
You can re-arrange or remove some of the sidebar boxes, by moving or removing the lines that start with $this
. For example, if you wish to move your new box to the top of your sidebar and remove the Free Text box, you would use the following code:
function Page::lay_print_sidebar { var string header; var string text;$header = "Your Header"; $text = """ <div class="columnitem"> Your text/HTML here </div> """; print_box($header, $text);$this->lay_print_summary(); $this->print_linklist(); $this->lay_print_calendar(); }
Compile your layer, and it's ready to use. You will need to apply your theme layer via the Customize interface in order for your changes to take effect.
Written by </a></b></a>camomiletea, based on tutorials by </a></b></a>
xevinx.