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

Have plugin appear on 'discussionscontroller' as well

2»

Comments

  • Options
    peregrineperegrine MVP
    edited April 2013

    change

       public function DiscussionController_BeforeCommentMeta_Handler($Sender) {
        to
       
     public function attach_votelink($Sender) {
    
    

    ok.

    next add these lines above it.

     public function DiscussionController_BeforeCommentMeta_Handler($Sender) {
    $this->attach_votelink($Sender);
    }
    public function DiscussionsController_BeforeDiscussionContent_Handler($Sender) {
    $this->attach_votelink($Sender);
    }
    

    actually after looking at your image you already have the vote mechanism it in the discussion page. What isn't working? and may not need to do what I suggested.

    I'm going to have to bail on this one. sorry. I've got some other things I need to work on, that I am receiving contributions for.

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

  • Options
    kirkpa31kirkpa31 ✭✭
    edited April 2013

    sorry for making you post again! My post above has been edited b/c I was rash and put the code in the wrong place. Quick screenshot of the code that you've implemented:

    image

    Thank you so much @peregrine!!

    I will let you know as soon as I can figure out the css and js to make this work.

    And that image above was an ideal shot, I cut and pasted the voting icons in there from a screenshot. Hopefully I can get this to look like that soon.

  • Options
    peregrineperegrine MVP
    edited April 2013

    so actually the changes helped you get further???

    now i'm confused.

    I suspect V could help you with the css (I feel like I am wasting my time when I deal with .css, I find it extremely tedious).

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

  • Options
    kirkpa31kirkpa31 ✭✭
    edited April 2013

    Yes definitely. You and @vrijvlinder are miracle workers. The box does appear, albeit above each discussion on the main page, but that is changeable via css hopefully. I will give this a go.

    But the boxes right now are not functional, I'm assuming with some js luck I can get that to change as well.

  • Options
    vrijvlindervrijvlinder Papillon-Sauvage MVP
    edited April 2013

    Yea that's great I was close but the Master exceeds any expectation, well that is why he is a Master and I am just an apprentice :) plus anymore herring and this thread would have to be closed from the stink lol

  • Options

    @peregrine said:

    now i'm confused.

    I suspect V could help you with the css (I feel like I am wasting my time when I deal with .css, I find it extremely tedious).

    Right, as my above post - boxes show up but do not collect votes when clicked - css is a little screwed up but that is fixable I believe.

    I will continue to work on this now that I have an excellent start.

  • Options
    peregrineperegrine MVP
    edited April 2013

    Yea that's great I was close but the Master exceeds any expectation, well that is why he is a Master and I am just an apprentice :) plus anymore herring and this thread would have to be closed from the stink lol

    V,

    I'm sure you could get the .css fix before I could so that would make you the css Master, plus you like fooling with css, and I don't

    and the when you get it working you can fork it on github or post your completed zip.

    when making zips its a good idea to zip the folder with the files, not just the files,
    then it will extract into a self-contained folder, unlike your previous zip.

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

  • Options
    vrijvlindervrijvlinder Papillon-Sauvage MVP
    edited April 2013

    yea you might need to add this part under the ones you added I am guessing you need it to add the jscss

    public function attach_votelink($Sender) {
    $this->attach_votelink($Sender);
    $this->AddJsCss($Sender);
    
  • Options

    the js is already added - but it will probably need some additions.

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

  • Options
    vrijvlindervrijvlinder Papillon-Sauvage MVP

    @kirkpa31 well when you get it online link me and I can help you fix the css for it.

    @peregrine thanks but I am only a Master Firebugger :)

  • Options

    @kirkpa31 - undo the changes I gave you previously and add this function (and the voting should work, no need to change the js as far as I can see. and all you need is V to help with css, and you should be set

         public function DiscussionsController_BeforeDiscussionContent_Handler($Sender) {
    
        echo '<span class="Votes">';
                $Session = Gdn::Session();
                $Object = ($Sender->EventArguments['Discussion']);
                $VoteType = 'votediscussion';
                $ID = $Object->DiscussionID;
                $CssClass = '';
                $VoteUpUrl = '/discussion/'.$VoteType.'/'.$ID.'/voteup/'.$Session->TransientKey().'/';
                $VoteDownUrl = '/discussion/'.$VoteType.'/'.$ID.'/votedown/'.$Session->TransientKey().'/';
                if (!$Session->IsValid()) {
                    $VoteUpUrl = Gdn::Authenticator()->SignInUrl($Sender->SelfUrl);
                    $VoteDownUrl = $VoteUpUrl;
                    $CssClass = ' SignInPopup';
                }
                echo Anchor(Wrap(Wrap('Vote Up', 'i'), 'i', array('class' => 'ArrowSprite SpriteUp', 'rel' => 'nofollow')), $VoteUpUrl, 'VoteUp'.$CssClass);
                echo Wrap(StringIsNullOrEmpty($Object->Score) ? '0' : Gdn_Format::BigNumber($Object->Score));
                echo Anchor(Wrap(Wrap('Vote Down', 'i'), 'i', array('class' => 'ArrowSprite SpriteDown', 'rel' => 'nofollow')), $VoteDownUrl, 'VoteDown'.$CssClass);
            echo '</span>';
        }
    

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

  • Options
    kirkpa31kirkpa31 ✭✭
    edited April 2013

    @vrijvlinder

    Thank you for your offer to help! The url is: idenitties.com/

    I am having trouble getting this voting box to change shape/color/size/anything right now. I have been getting slowly better at CSS using the Inspect Element aspects of Chrome and Firefox that you have heavily endorsed, but now I seem to be stumped. Will keep working on this.

  • Options

    @kirkpa31

    did you see the changes above.

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

  • Options
    kirkpa31kirkpa31 ✭✭
    edited April 2013

    Yup! And it worked perfectly! The voting is now functional. Thank you, thank you, as I was dreading my attempt to edit the .js file -> you've again saved me @peregrine.

  • Options
    vrijvlindervrijvlinder Papillon-Sauvage MVP
    edited April 2013

    I added width to this, you can also change the color etc with this code. Add it to the vote plugin css or your custom theme css which ever works

    
    body.Vanilla.Discussions ul.DataList.Discussions li.Item  span.Votes a.VoteUp {
    padding: 5px 4px 3px;
    -webkit-border-radius: 3px 3px 0 0;
    -moz-border-radius: 3px 3px 0 0;
    line-height: 100%;
    width: 35px;
    float:right;
    }
    
    body.Vanilla.Discussions ul.DataList.Discussions li.Item span.Votes a.VoteDown {
    padding: 3px 4px 5px;
    -webkit-border-radius: 0 0 3px 3px;
    -moz-border-radius: 0 0 3px 3px;
    line-height: 100%;
    width: 35px;
    float:right;
    }
    body.Vanilla.Discussions ul.DataList.Discussions li.Item span.Votes a {
    color:#eeeeee;
    background: #a23334;
    }
    body.Vanilla.Discussions ul.DataList.Discussions li.Item span.Votes span {
    padding: 0 4px !important;
    background:#ca5758;
    color:#eeeeee !important;
    width: 35px;
    float:right;
    }
    
  • Options
    peregrineperegrine MVP
    edited April 2013

    the css looks like the hardest part now! But I have faith in V.

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

  • Options

    @vrijvlinder

    It worked!!!!!

    Sorry for the delayed response to your CSS - but I've been playing with it non stop since you've posted it and I wanted to get it exactly right without having to bug you any more than I already have. Included is what I've modified to your CSS to get it to display the voting outside of the body and have it look like it does within each post:

    ul.DataList.Discussions li.Item  span.Votes a.VoteUp {
    padding: 3px 4px 3px;
    -webkit-border-radius: 3px 3px 0 0;
    -moz-border-radius: 3px 3px 0 0;
    line-height: 100%;
    }
    
    ul.DataList.Discussions li.Item span.Votes a.VoteDown {
    padding: 3px 4px 3px;
    -webkit-border-radius: 0 0 3px 3px;
    -moz-border-radius: 0 0 3px 3px;
    line-height: 100%;
    }
    ul.DataList.Discussions li.Item span.Votes a {
    color:#eeeeee;
    background: #a23334;
    }
    ul.DataList.Discussions li.Item span.Votes span {
    padding: 0 4px !important;
    background:#ca5758;
    color:#eeeeee !important;
    min-width: 36px;
    text-align: center;
    font-weight: bold;
    font-size: 18px;
    line-height: 1.2;
    }
    ul.DataList.Discussions span.Votes {
        text-align: center;
        display: block;
        position: absolute;
        right: 840px;
        line-height: normal;
        padding: 0;
    }
    

    That last part, starting ul.DataList.Discussions span.Votes { I added by changing ul.MessageList div.Meta span.Votes span { - code that is already in the css of the plugin that defines how the icon looks, that controls how far right/left the voting icon is on the page, as well as to put the 'vote up' and 'vote down' arrows on top and bottom of the span, rather than side by side.

    Other than that, just a few tiny changes to your code made it perfect.

    THANK YOU VRIJVLINDER

    And

    THANK YOU @PEREGRINE

    Screenshot (NOT PHOTOSHOPPED THIS TIME!):

    image

  • Options
    vrijvlindervrijvlinder Papillon-Sauvage MVP

    Good for you ! yea I wasn't sure how you wanted it so I included the body part in the code in case you wanted it to look different than the other pages. Now you know that by adding the body as in body.Vanilla.Discussions or body.Vanilla.Categories that it will only make the change specifically on that page. In case you want to just make the changes on one page/body

  • Options

    That makes sense, and is good to know in case things change! Many many thanks.

  • Options

    nice job @kirkpa

    and @vrijvlinder for the css tips.

    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.