Topic on Project:Support desk

add non-collapsible or by default expanded sidebar

5
Nicolasbock (talkcontribs)

Using the SkinBuildSidebar hook I can add a sidebar which by default is of class portal and can be collapsed. How would I add a sidebar that is of class portal.persistent so that the user cannot collapse it?

Thanks already,

nick

  • MediaWiki: 1.20.4
  • PHP: 5.4.13--pl0-gentoo (apache2handler)
  • MySQL: 5.1.67-log
MarkAHershberger (talkcontribs)

Could you show us your current code?

Nicolasbock (talkcontribs)

I load an extension in LocalSettings.php via require_once() and in that extension I have this code:

function shareSidebar ( $skin, &$bar )
{
        global $wgOut;
        $bar['Share'] = '<div class="ShareBar" id="sharetoolbar">
                         <table width="120" border="0" align="left">
                           <tr>
                             <td align="left">
                               <a href="http://flattr.com/thing/95652/FreeON-A-linear-scaling-electronic-structure-code" target="_blank"><img src="http://api.flattr.com/button/flattr-badge-large.png" alt="Flattr this" title="Flattr this" border="0" /></a>
                             </td>
                           </tr>
                         </table>
                         </div>';

        return true;
}

$wgHooks['SkinBuildSidebar'][] = 'shareSidebar';
MarkAHershberger (talkcontribs)

So, my wiki doesn't have the Vector extension and therefore doesn't have collapsible sidebars.

I enabled it and poked around in the various ways to modify a hook.

One way to do it is to use another hook, SkinTemplateToolboxEnd, and just use echo in your function to put the button at the end of the toolbox section. It is still collapsible, but the Toolbox is usually displayed by default.

The other (and probably what you want) is to add this bit to your Common.js:

 $("#p-Share").attr("class", "portal persistent");
Nicolasbock (talkcontribs)

Thanks for the reply! I tried the Common.js approach by creating the page Mediawiki:Common.js and copying your code into it. That's what I was looking for, thanks again!

Reply to "add non-collapsible or by default expanded sidebar"