Please upgrade here. These earlier versions are no longer being updated and have security issues.

Custom Sidebar Panel

edited November 2010 in Vanilla 2.0 - 2.3
I may have totally missed this but I feel like I have been searching for hours. How can I customize the sidebar panel. I noticed that on this forum you have a My Profile box. I would like to do something similar. What file must I modify?
Tagged:

Comments

  • TimTim Operations Vanilla Staff
    You need to create a plugin that contains a module. Check out the WhosOnline plugin as a good example of this kind of feature.

    Vanilla Forums COO [GitHub, Twitter, About.me]

  • I have to create a whole plugin just to add something to the sidebar panel?
  • TimTim Operations Vanilla Staff
    Well, were is the data going to come from? How is it going to function?

    If by "whole plugin" you mean 1 file called default.php with one method called Base_Render_Before() containing maybe 3 lines of code to include the module... then yes. A whole plugin :p

    Vanilla Forums COO [GitHub, Twitter, About.me]

  • TimTim Operations Vanilla Staff
    On the other hand, if all you want to add is a snippet of HTML or text, you can use Messages to do that.

    Dashboard > Messages

    Vanilla Forums COO [GitHub, Twitter, About.me]

    vintprox
  • I'm sorry if I am coming off poorly, but I have been trying to figure out the structure of Vanilla and I feel like the learning curve is pretty steep. The plugin you suggested I look at seemed complex, but I am new to OOP.

    All I want to do is add the login form that appears on http://support.bavotasan.com/vanilla/entry/signin to the sidebar panel on the index page where the welcome box is. I would like to have it there instead of appear in the popup. I would also like to do something similar to the My Profile box that is on this site.
  • I seem to be on the right track. I dissected Mark's In This Discussion plugin and was able to add something to the sidebar. Now I need to figure out how to order the items in the sidebar panel and how to call the contents of the module that creates the signin form on this page: http://support.bavotasan.com/vanilla/entry/signin. Any help would be amazing.

    Thanks.
  • TimTim Operations Vanilla Staff
    Ordering the modules:
    $Configuration['Modules']['Vanilla']['Panel'] = array('NewDiscussionModule', 'SignedInModule', 'GuestModule', 'Ads');

    Vanilla Forums COO [GitHub, Twitter, About.me]

  • Thanks for pointing me in the right direction. I think I figured most of it out, but I still can't get the panel order to change. I have tried modifying the $Configuration['Modules']. I modified it in the config-default.php file. I added it to config.php and tried to modify it there but that also didn't work. What am I missing?
  • True, changing `$Configuration['Modules']['Vanilla']['Panel']` doesn't affect the order and display of modules in the panel asset...

    Bug?

  • R_JR_J Cheerleader & Troubleshooter Munich Moderator



    It has worked some versions ago, so I'd say it is a bug. In the Gdn_Controller there is the following property:

       /**
        * @var string An associative array of assets and what order their modules should be rendered in.
        * You can set module sort orders in the config using Modules.ModuleSortContainer.AssetName.
        * @example $Configuration['Modules']['Vanilla']['Panel'] = array('CategoryModule', 'NewDiscussionModule');
        */
       public $ModuleSortContainer;
    

    The inline documentation suggests that this is the way to achieve a sort, but later on you can find this code:

       public function __construct() {
           ...
           $this->ModuleSortContainer = '';
           ...
       }
    

    And it is not filled anywhere with values from the config before it is used:

       public function getAsset($assetName) {
           if (!array_key_exists($assetName, $this->Assets)) {
               return '';
           }
           if (!is_array($this->Assets[$assetName])) {
               return $this->Assets[$assetName];
           }
    
           // Include the module sort
           $modules = array_change_key_case(c('Modules', []));
           $sortContainer = strtolower($this->ModuleSortContainer);
           $applicationName = strtolower($this->Application);
    
           if ($this->ModuleSortContainer === false) {
               $moduleSort = false; // no sort wanted
           } elseif (isset($modules[$sortContainer][$assetName])) {
               $moduleSort = $modules[$sortContainer][$assetName]; // explicit sort
           } elseif (isset($modules[$applicationName][$assetName])) {
               $moduleSort = $modules[$applicationName][$assetName]; // application default sort
           }
    

    Since the $this->ModuleSortContainer is always an empty string, the last if condition will always match and no sort will happen.


    To fix this, adding this to your theme/a plugin should recreate the sort method again:

       public function base_render_before($sender) {
           $sender->ModuleSortContainer = Gdn::config('Modules.Vanilla.Panel');
       }
    


Sign In or Register to comment.