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.

Have plugin appear on 'discussionscontroller' as well

Possible to have this plugin appear on the main page ('discussionscontroller') in addition to appear within each post ('discussioncontroller')? I ask this b/c of the peregrine voting leaderboard plugin (which I now love), I would like it to be possible to scroll the main page and vote on topics without having to click on the topic first and then vote.

Will continue to look through the different files in the voting plugin and report back if I find anything.

«1

Comments

  • hgtonighthgtonight ∞ · New Moderator

    @kirkpa31 It appears the features you are looking for might be in version 1.1.3. You can find it on github.

    I don't suggest you use this, unless you are comfortable finding and reporting bugs. I do suggest this in the hopes you will try to understand the differences. :D

    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.

  • Thank you @hgtonight. At first quick run it is horribly messing up the formatting of my page - but hopefully with time I'm able to figure this out.

  • kirkpa31kirkpa31 ✭✭
    edited April 2013

    Can't figure it out for the life of me using that github link. Last couple hours unfortunately wasted a little looking at the voting plugin and this stuff . Progress I've made: a screen shot of what I have in mind?

    image

    Hopefully the next couple hours of my attempting go better. It would work excellently well with @peregrine's voting leaderboard plugin.

  • kirkpa31kirkpa31 ✭✭
    edited April 2013

    Changed within plugins/Voting/class.voting.plugin.php

    from

    * Add the vote.js file to discussions page, and handle sorting of answers. */ public function DiscussionController_Render_Before($Sender) { // if (!C('Plugins.Voting.Enabled')) // return; $this->AddJsCss($Sender); }

    to

    public function Base_Render_Before($Sender) { // ($DisplayOn = array('discussioncontroller', 'discussionscontroller'); if (!InArrayI($Sender->ControllerName, $DisplayOn)) return;; $Sender->AddJsFile; }

    to no avail. Hoping that I'm at least on the right track.

    EDIT

    looking through the file again, i think the code under this header is the one that needs to be edited:

    /** * Increment/decrement discussion scores */

  • vrijvlindervrijvlinder Papillon-Sauvage MVP
    edited April 2013

    When I look at the class.voting.php

    I notice it has commented out stuff and the echo to the discussion

    /**
         * Add the "Stats" buttons to the discussion list.
         */
        public function Base_BeforeDiscussionContent_Handler($Sender) {
    //      if (!C('Plugins.Voting.Enabled'))
    //          return;
    
            $Session = Gdn::Session();
            $Discussion = GetValue('Discussion', $Sender->EventArguments);
            // Answers
            $Css = 'StatBox AnswersBox';
            if ($Discussion->CountComments > 1)
                $Css .= ' HasAnswersBox';
                
            $CountVotes = 0;
            if (is_numeric($Discussion->Score)) // && $Discussion->Score > 0)
                $CountVotes = $Discussion->Score;
                
            if (!is_numeric($Discussion->CountBookmarks))
                $Discussion->CountBookmarks = 0;
                
            echo Wrap(
                // Anchor(
                Wrap(T('Comments')) . Gdn_Format::BigNumber($Discussion->CountComments - 1)
                // ,'/discussion/'.$Discussion->DiscussionID.'/'.Gdn_Format::Url($Discussion->Name).($Discussion->CountCommentWatch > 0 ? '/#Item_'.$Discussion->CountCommentWatch : '')
                // )
                , 'div', array('class' => $Css));
            
            // Views
            echo Wrap(
                // Anchor(
                Wrap(T('Views')) . Gdn_Format::BigNumber($Discussion->CountViews)
                // , '/discussion/'.$Discussion->DiscussionID.'/'.Gdn_Format::Url($Discussion->Name).($Discussion->CountCommentWatch > 0 ? '/#Item_'.$Discussion->CountCommentWatch : '')
                // )
                , 'div', array('class' => 'StatBox ViewsBox'));
        
            // Follows
            $Title = T($Discussion->Bookmarked == '1' ? 'Unbookmark' : 'Bookmark');
            if ($Session->IsValid()) {
                echo Wrap(Anchor(
                    Wrap(T('Follows')) . Gdn_Format::BigNumber($Discussion->CountBookmarks),
                    '/vanilla/discussion/bookmark/'.$Discussion->DiscussionID.'/'.$Session->TransientKey().'?Target='.urlencode($Sender->SelfUrl),
                    '',
                    array('title' => $Title)
                ), 'div', array('class' => 'StatBox FollowsBox'));
            } else {
                echo Wrap(Wrap(T('Follows')) . $Discussion->CountBookmarks, 'div', array('class' => 'StatBox FollowsBox'));
            }
        
            // Votes
            if ($Session->IsValid()) {
                echo Wrap(Anchor(
                    Wrap(T('Votes')) . Gdn_Format::BigNumber($CountVotes),
                    '/vanilla/discussion/votediscussion/'.$Discussion->DiscussionID.'/'.$Session->TransientKey().'?Target='.urlencode($Sender->SelfUrl),
                    '',
                    array('title' => T('Vote'))
                ), 'div', array('class' => 'StatBox VotesBox'));
            } else {
                echo Wrap(Wrap(T('Votes')) . $CountVotes, 'div', array('class' => 'StatBox VotesBox'));
            }
        }
    
    

    Maybe all you need to do is uncomment the stuff so it works also for the discussion list or other..

  • Unfortunately all that does, as far as I can see, is that the image are removed.

    I have been looking inside of the Fancybox plugin looking for code that I changed to activate it on the discussionscontroller page, which I implemented in my earlier attempt on this page. No luck thus far.

  • vrijvlindervrijvlinder Papillon-Sauvage MVP
    edited April 2013

    have you tried adding this? This part I believe is what inserts the stuff all you would need could be to add the controller you want but be warned it can be a red herring ! lol

    
    
    
           /**
         * Insert the voting html to another controller.
         */
        public function DiscussionsController_BeforeItemContentDiscussionMeta_Handler($Sender) {
    //      if (!C('Plugins.Voting.Enabled'))
    //          return;
    
            $this->DiscussionsController_BeforeItemContentDiscussionMeta_Handler($Sender);
                    
        }
    
               
        /**
         * Add voting css to discussions controller.
         */
        public function DiscussionsController_Render_Before($Sender) {
    
    //      if (!C('Plugins.Voting.Enabled'))
    //          return;
    
          $this->AddJsCss($Sender);
        }
    
  • kirkpa31kirkpa31 ✭✭
    edited April 2013

    Added your code within, preview is below, but ERROR pages are something I've become accustomed to unfortunately, and it's what happens with this code.

  •     /**
         * Insert the voting html on comments in a discussion.
         */
        public function PostController_BeforeCommentMeta_Handler($Sender) {
    //      if (!C('Plugins.Voting.Enabled'))
    //          return;
    
            $this->DiscussionController_BeforeCommentMeta_Handler($Sender);
        }
    
            public function DiscussionsController_BeforeItemContentDiscussionMeta_Handler($Sender) {
    //      if (!C('Plugins.Voting.Enabled'))
    //          return;
    
            $this->DiscussionsController_BeforeItemContentDiscussionMeta_Handler($Sender);
    
        }
    
    
        /**
         * Add voting css to post controller.
         */
        public function PostController_Render_Before($Sender) {
    //      if (!C('Plugins.Voting.Enabled'))
    //          return;
    
          $this->AddJsCss($Sender);
        }
    
       public function ProfileController_Render_Before($Sender) {
    //      if (!C('Plugins.Voting.Enabled'))
    //          return;
    
          $this->AddJsCss($Sender);
       }
    
           public function DiscussionsController_Render_Before($Sender) {
    
    //      if (!C('Plugins.Voting.Enabled'))
    //          return;
    
          $this->AddJsCss($Sender);
        }
    
  • peregrineperegrine MVP
    edited April 2013

    @kirkpa31

    post a zip of your complete mods, and I 'll have a look if you want.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • vrijvlindervrijvlinder Papillon-Sauvage MVP
    edited April 2013

    yea but what are the error messages , data error on? that gives a clue and tells what line where. Is it syntax error?

    Maybe you just need this part

    
    public function DiscussionsController_BeforeDiscussion_Handler($Sender) {
    
            $this->DiscussionsController_BeforeDiscussion_Handler($Sender);
                    
        }
     
               
      public function DiscussionsController_BeforeDiscussionRender_Handler($Sender) {
      
          $this->AddJsCss($Sender);
        }
    
    
  • Thank you @peregrine! I'm attaching a zip of my voting plugin - the only file I've done modifications to is voting.plugin.php, adding the

            public function DiscussionsController_BeforeItemContentDiscussionMeta_Handler($Sender) {
    //      if (!C('Plugins.Voting.Enabled'))
    //          return;
            $this->DiscussionsController_BeforeItemContentDiscussionMeta_Handler($Sender);
        }
    

    as posted above. I've removed modified part posted under

        /**
         * Add voting css to post controller.
         */
    

    b/c It caused my forum to flip out.

  • vrijvlindervrijvlinder Papillon-Sauvage MVP

    yea thanks @peregrine this thread was getting fishy from so much red herring !

  • @kirkpa31

    give me a day or two.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • @vrijvlinder

    The error message before that last bit you posted was:

    Fatal error: Cannot redeclare VotingPlugin::DiscussionsController_Render_Before() in /home/kirkpa31/public_html/plugins/Voting/class.voting.plugin.php on line 546

    Caused purely by the commented out bit of code under the "add voting css to post controller"

    // if (!C('Plugins.Voting.Enabled')) // return;

    Removing this, as you suggested in that last mod, removed the error but made no alterations in the voting plugin.

  • kirkpa31kirkpa31 ✭✭
    edited April 2013

    And Thank You @peregrine!

    I am incredibly grateful for yours and @vrijvlinder's support.

    I will also continue to work on this and will post back anything that I find to be potentially useful.

  • vrijvlindervrijvlinder Papillon-Sauvage MVP

    I will try this too see what goes now I am curious.... not as easy as it seems 0_o

    back to school I go :)

  • peregrineperegrine MVP
    edited April 2013

    this may get you somewhere. You will need to adjust .css and js

    but it will add a box to the left in discussions page - if thats what you want.

    change  
    
    public function DiscussionController_BeforeCommentMeta_Handler($Sender) {
    to
     public function  attach_votelink($Sender) {
    
    
    
    
    then add these
    
        public function DiscussionController_BeforeCommentMeta_Handler($Sender) {
    $this->attach_votelink($Sender);
         }
    
         public function DiscussionsController_BeforeDiscussionContent_Handler($Sender) {
    $this->attach_votelink($Sender);
         }
    

    you will need to figure out the proper .css - to get the box correct.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • kirkpa31kirkpa31 ✭✭
    edited April 2013

    EDIT

    @peregrine

    I was putting it in the wrong place....

    This does create a box!!!

    I will edit CSS and js, as you have recommended, and report back!

    Thank you!!!

  • peregrineperegrine MVP
    edited April 2013

    either what you posted is wrong or displaying wrong. You left out closing brace. or try again from scratch.

    Doing the sequence in order.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

Sign In or Register to comment.