Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.

How can you create left and right side panels from a plugin

+1 vote
75 views
asked Jul 15 in Plugins by JKY

http://www.question2answer.org/qa/51436/i-want-to-add-adverts-to-left-side-how-can-i-do-it
 

With no answer

http://www.question2answer.org/qa/55875/change-sidebar-from-right-to-left-snowflat?show=55880#a55880

Find .qa-sidepanel class in your theme css and modify it. You may also need to change document structure. Place .qa-sidepanel div before the .qa-main div.

The issue is using the CSS you can't differentiate between left and right side panels with only one class 

http://www.question2answer.org/qa/26517/how-have-side-top-left-right-bottom-just-like-wordpress-joomla?show=26641#a26641

jatin.soni's answer 

There is not such a system which allows you to register new sidebar only if you touch the core... but there are registered places where you can register your sidebar and I believe which is good enough.
 
Just check some widgets and find how you can register your widget/plugin for defining places and templates.

I have not found any existing plugins that illustrate this

http://www.question2answer.org/qa/50216/how-do-i-get-to-the-left-side-of-the-category-cleanstrap-theme

with no answer.

http://www.question2answer.org/qa/47694/sidepanel-on-the-left-instead-of-on-the-right?show=47699#a47699
Scott's answer 


The simplest way to do this is to edit your theme's CSS (located in qa-theme/<yourtheme>/qa-theme.css).

Find .qa-sidepanel and change from float: right to float: left.

Find .qa-main and change from float: left to float: right. 

I need a .qa-left-sidepanle that can float left 

http://www.question2answer.org/qa/55179/can-make-three-column-site-with-question2answer-application?show=55202#a55202

Now this is closer to what I need and  was answered vaguely but with some useful information 

All of this is so that you can see I have done my research.. 

how do you override the function sidepanel() and sidebar() from a plug in so that the 
allow_region($region) can be "left-side" and not just "side"
when using 

public function output_widget($region, $place, $themeobject, $template, $request, $qa_content)
{
$region = "left-side";

}

 removes the widget from the display and don't return an error 
 If I can  add the class or id of the div to be .qa-widget-left-side then in the CSS I can move the item on the screen and display it. 

So how can this been done? 

will it be compatible with 1.8?

Q2A version: 1.7.4

1 Answer

+1 vote
answered Jul 17 by Scott

It might be possible with a core hack. In qa-include/app/page.php and qa-include/pages/admin/admin-widgets.php look for the $regioncodes variables and add 'L' => 'leftside' to the array. (Those variables ought to be defined in one place instead of duplicated code but anyway...)

Then, in your advanced theme override the sidepanel() function and add your left sidepanel. Example:

public function sidepanel()
{
    $this->output('<div class="qa-sidepanel-left">');
    $this->widgets('leftside', 'top');
    $this->widgets('leftside', 'bottom');
    $this->output('</div>', '');

    parent::sidepanel();
}

You could also add high/low if needed. Then in your plugin use 'leftside' as the region name.


A slightly simpler method, without a core hack, would be to use the top/bottom 'place codes' on one side and high/low on the other. You can do a similar theme override to above:

public function sidepanel()
{
    $this->output('<div class="qa-sidepanel-left">');
    $this->widgets('side', 'top');
    $this->widgets('side', 'bottom');
    $this->output('</div>', '');

    $this->output('<div class="qa-sidepanel">');
    $this->widgets('side', 'high');
    $this->sidebar();
    $this->widgets('side', 'low');
    $this->output_raw(@$this->content['sidepanel']);
    $this->feed();
    $this->output('</div>', '');
}

Then if you want a widget on the left, in the admin you can set it to "Side panel - Top" or "Side panel - Last". If you want it on the right, use "Side panel - Below sidebar box" or "Side panel - Below categories".

This does remove a little bit of flexibility as you can only put widgets in 2 locations, not 4. But you can experiment with moving around the various lines there.

commented Jul 17 by JKY
Thank you for a very well written example.. I will be trying to hack the core for the most flexibility..
...