1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  1. Nick

    Nick Well-Known Member

    Nick submitted a new resource:

    Who Voted - Who Voted

    Read more about this resource...
     
    Last edited by a moderator: Oct 24, 2014
    loganimal, baadier and apfind like this.
  2. apfind

    apfind New Member

    Awesome! Great work Nick!
     
  3. maxmk

    maxmk Active Member

    Great work.. I was looking for this module.. :)

    Thanks
     
  4. Nick

    Nick Well-Known Member

    LOL, so was I! I made it back in January and completely forgot to upload it here!
     
    Bill_C likes this.
  5. Stuart

    Stuart Well-Known Member

    Hey all,

    When building a new Hotaru theme I found that the who_voted plugin did not have a main div container for styling.

    Original Code
    Code:
            if ($results) 
            {
                if ($show_title) {
                    $output .= "<h2 id='who_voted_title'>" . $h->lang['who_voted'] . "</h2>";
                }
            
                $output .= "<div id='who_voted_content'>\n";
                foreach ($results as $item) {
                    $h->setAvatar($item->user_id, $avatar_size);
                    if ($avatars) {
                        $output .= $h->linkAvatar(); 
                    }
                    if ($names) {
                        $output .="<a href='" . $h->url(array('user' => $item->user_username)) . "'>" . $item->user_username . "</a> &nbsp;\n";
                    }
                }
                $output .= "</div>\n";
                $output .= "</div>\n";
            }
            else 
            {
                // Show "No other posts found with matching tags"
                $output .= "<div id='who_voted'>\n";
                $output = "<div id='who_voted_content'>\n";
                $output .= $h->lang['who_voted_no_results'];
                $output .= "</div>\n";
            }
    
            return $output;
        }
    
    As you can see the content ie avatars and usernames content is wrapped in a div "who_voted_content" but the H2 sits out with a container div. This makes say for example placing a box border around all the who voted content including title pretty hard.

    To over come this I added an extra div titled whoo_voted to wrap all the content including the H2 title. It's now much easier to theme up the who voted on post pages with CSS. :)

    Edited Code
    Code:
            if ($results) 
            {
                $output .= "<div id='who_voted'>\n";
                if ($show_title) {
                    $output .= "<h2 id='who_voted_title'>" . $h->lang['who_voted'] . "</h2>";
                }
            
                $output .= "<div id='who_voted_content'>\n";
                foreach ($results as $item) {
                    $h->setAvatar($item->user_id, $avatar_size);
                    if ($avatars) {
                        $output .= $h->linkAvatar(); 
                    }
                    if ($names) {
                        $output .="<a href='" . $h->url(array('user' => $item->user_username)) . "'>" . $item->user_username . "</a> &nbsp;\n";
                    }
                }
                $output .= "</div>\n";
                $output .= "</div>\n";
            }
            else 
            {
                // Show "No other posts found with matching tags"
                $output .= "<div id='who_voted'>\n";
                $output = "<div id='who_voted_content'>\n";
                $output .= $h->lang['who_voted_no_results'];
                $output .= "</div>\n";
                $output .= "</div>\n";
            }
    
            return $output;
        }
    
    I have also included an updated version of the module for anyone not comfortable mucking around with code. ;) Hopefully this small but useful tweak can be added to the official module for others to use.
     

    Attached Files:

  6. shibuya246

    shibuya246 Hotaru Developer Staff Member Admin

  7. robin007

    robin007 Well-Known Member

    Next version.
    Please provide two widget like
    who up voted
    who down voted
     

Share This Page