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.

Can we show the user's points next to their Username like on Reddit?

Hi everyone - I was wondering if there is a simple way to show a user's points next to their username on all pages? Just like on Reddit.

I have found myself looking at my points every time I refresh a page to see if I got an upvote :p so I was thinking this could be a pretty good incentive to have on our vanilla forums :)

Just to clarify, by points I mean the dt.Points which you see when on your userpage.

I have some JQuery going on in my website, so that could be an option. I'm aware how to move divs around with InsertAfter, but I don't know how to call dt.Points to load on all pages. Is it maybe as easy as inserting a {points} or similar code into the theme's html file?

Thanks for any replies! I think this feature would be very useful to many people, and maybe even worth adding into the core if many people agree with me

Comments

  • Cool guys, I found a solution. Simply use use the feature {module name="UserInfoModule"} in your theme's .tpl to bring the whole info box to your page, and move stuff around from there. Easy fix

  • Great that you found a solution to work with. But if you want to spice up your own theme with some info here and there, you might be interested how this could be done also quite easy.

    From what you have written above I would say you already have a custom theme, let's call it "groovy" (I like that word). So you have a folder called /themes/groovy. Take the code below and save it as /themes/groovy/class.groovythemehooks.php

    <?php
    
    class GroovyThemeHooks implements Gdn_IPlugin {
        /**
         * Code in here will be executed once, when the theme is enabled.
         *
         * This is not used here, but must be in the ThemeHooks file.
         *
         * @return void.
         */
        public function setup() {
        }
    
        /**
         * Code in here will be executed once, when the theme is disabled.
         *
         * This is not used here, but must be in the ThemeHooks file.
         *
         * @return void.
         */
        public function onDisable() {
        }
    
        /**
         * Echo user score whenever AuthorInfo is fired.
         *
         * @param VanillaController $sender Instance of the calling class.
         * @param mixed             $args   Event arguments.
         *
         * @return void.
         */
        public function base_authorInfo_handler($sender, $args) {
            echo '<span class="MItem AuthorScore">'.$args['Author']->Score.'</span>';
        }
    }
    

    Whenever you want to insert information bits, you "only" need to know where you are able to insert what information.
    Drop a note if that's of interest and you need more information or simply search this forum for "fireEvent" ;)

Sign In or Register to comment.