(Created page with "So you like the idea of having a new special sidebar as it suits the approach you want to take on a particular project. It's actually rather quick and easy to accomplish, alth...") |
|||
| Line 21: | Line 21: | ||
# MoreFoot Right | # MoreFoot Right | ||
# Footer Columns Sidebar | # Footer Columns Sidebar | ||
| + | |||
| + | Now that we know what we have and where they fit into the scheme of things, lets look at adding our custom sidebar to the mix. | ||
| + | |||
| + | To keep things simple, we will simply start with the ''Primary Sidebar''. All of the default sidebars are actually sections, so if we break out our text editor of choice we can locate the following file in the PageLines framework installation folder: | ||
| + | ..\sections\sb_primary\section.php | ||
| + | |||
| + | Also, for the purposes of this tutorial I will only be using a portion of the code found in the file that is directly associated with this exercise. | ||
| + | |||
| + | <syntaxhighlight>class PrimarySidebar extends PageLinesSection { | ||
| + | /** PHP that always loads no matter if section is added or not. */ | ||
| + | function section_persistent() { | ||
| + | $setup = pagelines_standard_sidebar($this->name, $this->settings['description']); | ||
| + | pagelines_register_sidebar($setup, 1); | ||
| + | } | ||
| + | |||
| + | /** Section template. */ | ||
| + | function section_template() { | ||
| + | pagelines_draw_sidebar($this->id, $this->name, 'includes/widgets.default'); | ||
| + | } | ||
| + | }</syntaxhighlight> | ||
| + | |||
| + | Of course we need to make some basic changes to this code in order to use it for our custom sidebar so let's look at what needs to be changed: | ||
| + | |||
| + | # PrimarySidebar should be changed to something more appropriate, we'll use MyCustomSidebar for this tutorial. | ||
| + | # The value set in [[pagelines_register_sidebar]] should be set to something greater than 10, we'll use 100 in this example | ||
| + | # The [[pagelines_draw_sidebar]] default can be set to an empty string as we intend to have our own custom content used in this widget area. | ||
| + | |||
| + | Let's look at the MyCustomSidebar code now: | ||
| + | <syntaxhighlight>class MyCustomSidebar extends PageLinesSection { | ||
| + | /** PHP that always loads no matter if section is added or not. */ | ||
| + | function section_persistent() { | ||
| + | $setup = pagelines_standard_sidebar($this->name, $this->settings['description']); | ||
| + | pagelines_register_sidebar($setup, 100); | ||
| + | } | ||
| + | |||
| + | /** Section template. */ | ||
| + | function section_template() { | ||
| + | pagelines_draw_sidebar($this->id, $this->name, ''); | ||
| + | } | ||
| + | }</syntaxhighlight> | ||
So you like the idea of having a new special sidebar as it suits the approach you want to take on a particular project. It's actually rather quick and easy to accomplish, although there are several items you should take note of to make your developing life a bit easier.
First off, I strongly recommend you turn on sidebar prioritization. This feature can be found under the main PageLines menu: Settings > Advanced. Once there just scroll down to the Sidebar Priority option and check the box for "Enable sidebar priorities?" Remember to click the "Save Options" button.Please note, this is a PRO feature; you will need to be using a Professional License version of the framework, or Developer License version. See this page for more details regarding these licenses.
Now that we have set the Sidebar Priorities, lets have a look at widgets in the WordPress Administration Panels. Go to Appearance > Widgets and you should see something similar to the image below.
The priority sequence for the default registered sidebar widget areas follows this order:
Now that we know what we have and where they fit into the scheme of things, lets look at adding our custom sidebar to the mix.
To keep things simple, we will simply start with the Primary Sidebar. All of the default sidebars are actually sections, so if we break out our text editor of choice we can locate the following file in the PageLines framework installation folder:
..\sections\sb_primary\section.php
Also, for the purposes of this tutorial I will only be using a portion of the code found in the file that is directly associated with this exercise.
class PrimarySidebar extends PageLinesSection {
/** PHP that always loads no matter if section is added or not. */
function section_persistent() {
$setup = pagelines_standard_sidebar($this->name, $this->settings['description']);
pagelines_register_sidebar($setup, 1);
}
/** Section template. */
function section_template() {
pagelines_draw_sidebar($this->id, $this->name, 'includes/widgets.default');
}
}
Of course we need to make some basic changes to this code in order to use it for our custom sidebar so let's look at what needs to be changed:
Let's look at the MyCustomSidebar code now:
class MyCustomSidebar extends PageLinesSection {
/** PHP that always loads no matter if section is added or not. */
function section_persistent() {
$setup = pagelines_standard_sidebar($this->name, $this->settings['description']);
pagelines_register_sidebar($setup, 100);
}
/** Section template. */
function section_template() {
pagelines_draw_sidebar($this->id, $this->name, '');
}
}