Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Options

LeaderBox on Bootstrap theme

Vanilla 2.2
Theme Bootstrap
Serveur de Test : http://88.181.151.128:8080/

Hi all,

I would like to have this on all pages

Despite my research, I can not do it:

https://vanillaforums.org/discussion/comment/220790#Comment_220790

https://blog.vanillaforums.com/help/vanilla-forums-friday-theme-tip-adding-leaderboard/

Thanks all

Tagged:

Comments

  • Options
    vrijvlindervrijvlinder Papillon-Sauvage MVP
    edited February 2016

    You would need to add the modules to you class.themehooks.php file from your theme if there is one. If you do not have one you can create one and call it class.bootstrapthemehooks.php or the name of the theme you are using and place it in the bootstrap theme folder.

    This is an example themehooks file only you need to find the real name of the module :

    <?php if (!defined('APPLICATION')) exit();
    
    class BootstrapThemeHooks implements Gdn_IPlugin {
    
    
        public function CategoriesController_Render_Before($Sender) { 
        //this checks that user is logged in to display the module only if user is logged in.
        if ($Session->IsValid()) {
        $this->AddModule('LeaderBoardModule');
         }
        }
        public function DiscussionController_Render_Before($Sender) { 
        if ($Session->IsValid()) {
        $this->AddModule('LeaderBoardModule');
         }
        }
        public function DiscussionsController_Render_Before($Sender) { 
        if ($Session->IsValid()) {
        $this->AddModule('LeaderBoardModule');
         }
        }
       public function Setup() {
            return TRUE;
       }
       public function OnDisable() {
          return TRUE;
       }
    
    }  
    
  • Options
    vrijvlindervrijvlinder Papillon-Sauvage MVP
    edited February 2016

    You could also edit the YAGA application.

    In the class.hooks.php in the settings folder for yaga file find line 566 look for this code

    public function ActivityController_Render_Before($Sender) {
        $this->_AddResources($Sender);
    
        if(C('Yaga.LeaderBoard.Enabled', FALSE)) {
          // add leaderboard modules to the activity page
          $Module = new LeaderBoardModule();
          $Module->GetData('w');
          $Sender->AddModule($Module);
          $Module = new LeaderBoardModule();
          $Sender->AddModule($Module);
        }
      }
    

    Then add bellow it

    public function DiscussionsController_Render_Before($Sender) {
        $this->_AddResources($Sender);
    
        if(C('Yaga.LeaderBoard.Enabled', FALSE)) {
          // add leaderboard modules to the discussions page
          $Module = new LeaderBoardModule();
          $Module->GetData('w');
          $Sender->AddModule($Module);
          $Module = new LeaderBoardModule();
          $Sender->AddModule($Module);
        }
      }
    
    public function CategoriesController_Render_Before($Sender) {
        $this->_AddResources($Sender);
    
        if(C('Yaga.LeaderBoard.Enabled', FALSE)) {
          // add leaderboard modules to the categories page
          $Module = new LeaderBoardModule();
          $Module->GetData('w');
          $Sender->AddModule($Module);
          $Module = new LeaderBoardModule();
          $Sender->AddModule($Module);
        }
      }
    
    public function DiscussionController_Render_Before($Sender) {
        $this->_AddResources($Sender);
    
        if(C('Yaga.LeaderBoard.Enabled', FALSE)) {
          // add leaderboard modules to the discussion page
          $Module = new LeaderBoardModule();
          $Module->GetData('w');
          $Sender->AddModule($Module);
          $Module = new LeaderBoardModule();
          $Sender->AddModule($Module);
        }
      }
    
    public function CategoryController_Render_Before($Sender) {
        $this->_AddResources($Sender);
    
        if(C('Yaga.LeaderBoard.Enabled', FALSE)) {
          // add leaderboard modules to the category page
          $Module = new LeaderBoardModule();
          $Module->GetData('w');
          $Sender->AddModule($Module);
          $Module = new LeaderBoardModule();
          $Sender->AddModule($Module);
        }
      }
    
    public function ProfileController_Render_Before($Sender) {
        $this->_AddResources($Sender);
    
        if(C('Yaga.LeaderBoard.Enabled', FALSE)) {
          // add leaderboard modules to the profile page
          $Module = new LeaderBoardModule();
          $Module->GetData('w');
          $Sender->AddModule($Module);
          $Module = new LeaderBoardModule();
          $Sender->AddModule($Module);
        }
      }
    
  • Options

    hi,

    Thank you for your answer,
    it not working (Error 500)
    I have put the code after line 606:

      public function ActivityController_Render_Before($Sender) {
        $this->AddResources($Sender);
    
        if(C('Yaga.LeaderBoard.Enabled', FALSE)) {
          // add leaderboard modules to the activity page
          $Module = new LeaderBoardModule();
          $Module->SlotType = 'w';
          $Sender->AddModule($Module);
          $Module = new LeaderBoardModule();
          $Sender->AddModule($Module);
        }
      }
    

    I also cleared the cache

  • Options
    hgtonighthgtonight ∞ · New Moderator

    If you want it on every page, I would disable the default display of the leaderboard via the yaga dashboard and add the module to every page via a plugin or via a smarty tag in your master template file.

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • Options
    TofTof
    edited February 2016

    ok thank

    What is the plugin ?

  • Options
    vrijvlindervrijvlinder Papillon-Sauvage MVP

    No, you did not understand, of course you get an error if add the same function. Please look at the second comment.

    The first code block is already there for the activity controller. You must add the others bellow that one. Do not add it twice.

    The themehooks file is like a plugin as the example in the first comment shows.

    Adding it to the master template will add the leaderboard in places that are not useful. In other words in every single page such as entry or plugin pages.

    If that is what you want then disable the leaderboard from the dashboard so it does not load it, but it will load via your theme. That is what hgtonight suggested.

  • Options

    Sorry my English is very bad ...

    I have not understood yet ...

    I open the file ../applications/yaga/setting/class.hooks.php

    I seek your second comment, that I understand

    I then tried to paste the code ... But still errors ...

    You can find my class.hooks.php file below:

    http://www.tablette-chinoise.net/Download/class.hooks.zip

  • Options
    vrijvlindervrijvlinder Papillon-Sauvage MVP

    Ok, see if this will work. Remember to disable the application and delete the .ini file from the cache before you re enable the Yaga application.

  • Options
    TofTof
    edited February 2016

    Thanks again,

    I can not activate YAGA with your file. (Cache cleared)

    I'm looking the code, this is normal?
    $this->_AddResources($Sender);

    I replaced with this:
    $this->AddResources($Sender);

    But, it's not working

  • Options
    vrijvlindervrijvlinder Papillon-Sauvage MVP
    edited February 2016

    No, I can't test all this now because I am traveling and don't have all my files with me. However if this still does not work, since i am not sure what the error is exactly, it should say in the cgi error logs where you host your files and forum. It could be something simple like an extra } or a missing } bracket. Or it could be something else but it would show in the error log.

    If this does not work, then try adding a themehooks file as example 1 in my first comment.

    Or add the module in the tpl of the theme in the panel asset div

    find asset panel in the default.master.tpl file from bootstrap theme add the module as I did bellow bellow the panel.

             {asset name="Panel"}
             {module name="LeaderBoardModule"}
    
  • Options
    TofTof
    edited February 2016

    Hi,

    I created a theme class.bootstrap hooks.php file to the root of the theme BOOTSTRAP

    I put in the information of example 1

    I'm an error 500

    Sorry ;)

  • Options
    vrijvlindervrijvlinder Papillon-Sauvage MVP

    Did you remember to disable the leaderboard from the dashboard ? If you add the hooks file and you do not disable the leaderboard from the dashboard, that could cause a problem.

    Try adding the third option to your default.master.tpl as already explained above please re read that part.

  • Options
    TofTof
    edited February 2016

    Hi,

    I disabled Leader BOX
    1. Replaced the class.hooks.php file
    2. clearing the cache
    Result : I always error 500

    In the second Temp

    1. Replaced the class.hooks.php file
    2. Added information in default.master.tpl
    3. clearing the cache
      Result: I always error 500
  • Options

    With only {module name="LeaderBoardModule"}
    The leaders of the display appears

    How can I make show Leader of the week (leader de la semaine)

  • Options
    TofTof
    edited February 2016

    It's ok

    just simply add this to his theme default.master.tpl

    Open
    default.master.tpl

    Find
    {asset name="Panel"}

    Add just after

        {module name="LeaderBoardModule" SlotType="w"}  
        {module name="LeaderBoardModule"}
    

    No changes to the file : class.hooks.php

Sign In or Register to comment.