Long time a go since I want to explain how the widgets in the sidebar works on OC.
First of all we need to understand how does it works and later I will explain how to create one.
In config.php we have a define called SIDEBAR.
define('SIDEBAR','item_tools,new,search,categories,adsense,popular,links');
Each item that would appear in the sidebar is separated by coma, and displayed in the same order.
The rest is handled in /includes/sidebar.php.
Here we read the define SIDEBAR and splitting by comas we call the functions.
The name of the functions mast be like sb_SOMENAME, where SOMENAME would be the one we type in the SIDEBAR define.
I think is easier if I do an example:
function sb_TEST($beg,$end){
return $beg."test function!".$end;
}
As you can see as parameters have $beg and $end, that should be the HTML code that we want to print with.
And to ad this function into the site in the SIDEBAR define we ad it like this:
define('SIDEBAR','item_tools,new,search,categories,adsense,popular,links,TEST');
This will load the function.
The function can be in the sidebar.php, or in a file functions.php that must be in the root of the theme.
I hope this is useful to all OC developers, that I see there’s many! 😉