hi guys:
I am testing a new site which uses vote up down and it is coming out nicely. Maybe you can have a look and tell me if I am doing things correctly.
Thanks.
The site is:
http://www.gadgetrank.com/ (this link is dead - 2007/12/13)

CommentFileSizeAuthor
#4 emptyvote3.15 KBmarcoBauli

Comments

marcoBauli’s picture

ezichko: wow, i'm impressed! That's simple yet very sexy and informative site! (so the answer is between the lines ;)

can i ask you how did you manage to show only points in teasers (i managed to show them only togheter with all the $links..) and to link to /user/register if anonymous (again, i only get a non-clickable "you must register to vote" description label similar to the ones you get when hovering over a menu item..)?!

cheers

frjo’s picture

Category: support » task

Very fun to see people doing cool stuff with my modules!

I see you have made the voting widget a link to user/login for not logged in users. Simple and nice solution! I should add that in some way to the module.

A tips for the image popups. I have made a simple wrapper module for Thickbox, a jQuery plugin.

ezichko’s picture

Thanks frjo. I had lightbox for image popups but it added more than 200k to the page load so I removed it. Thickbox looks like a better solution. I will try it.

Marcob, I got the code for anonymous somewhere here in the forums:

To implement this (on latest drupal4.7.3 and CVS version of
vote-up-down) you want to firstly determine if the user is anonymous or
logged in. If the user is not logged in, we want to place a javascript
on those up/down buttons which asks them to login.


*Change 1: node-storylink.tpl.php* ( place this around the code which
shows $vote_updown_widget , this will place the javascript where user
is anonymous and the regular widget when user is logged in )
__________________________________________________________

<?php global $user; 
    if ($user->uid) {
        print $vote_up_down_widget ;
    } else {
        print '<div class="vote-up-down-widget">    
            <a href="user/login" onclick="return(loginopen('.$id.'))">
                <span class="up-inact" title="You must login to vote."></span>
                <span class="down-inact" title="You must login to vote."></span>
            </a>
        </div>';    
    }
?>

*Change 2: node-storylink.tpl.php* ( We also have to add some unique id
to each node , so that we can display our login_request just below the
story where user clicked , so i added the story_number to each node_id.
This change is at the first line of file. )
______________________________________________________________
<!-- start node -->
<div id="node<?php print $id ?>" class="node<?php print ($sticky) ? ' sticky' : ''; ?>">


*Change 3 : ajax_vote_up_down.js* - Add these lines at the end ( this
is the actual javascript which asks anonymous users to login )
__________________________________________________________
// Javascript for redirecting not logged users to login page
function loginclose(){
poppDiv=$('poppDiv');
if(poppDiv){
poppDiv.parentNode.removeChild(poppDiv);
poppDiv=false;
}
}
function loginopen(id){
loginclose();
$('node'+id).innerHTML+='<div id="poppDiv" class="login-warning"><div><p>Please <a href="user/login">Login</a> or <a href="user/register">Register</a> to vote for links you like.</p><a href="javascript:loginclose()"><img src="/themes/xxx/images/close.gif" class="close" width="22" height="22" alt="Close" /></a></div></div>';
return(false);
}
marcoBauli’s picture

Status: Active » Needs review
StatusFileSize
new3.15 KB

ezchko: thanks for sharing this little gem!

I managed to get it to work for default up-down widget, but not for the ALTERNATIVE one.. no vote points nor plus simbol output, thus breaking the layout (see attached screenshot)

This is the code i used trying to make it work with the alternative widget:

  <?php global $user; 
    if ($user->uid) {
        print $vote_up_down_widget ;
    } else {
        print '<div class="vote-up-down-widget-alt">    
            <a href="user/login" onclick="return(loginopen('.$id.'))">
                <span class="vote-points" title="You must login to vote."></span>
                <span class="up-inact" title="You must login to vote."></span>
            </a>
        </div>';    
    }
?>

do you have by chance a quick help? ..or i will wait for this to be committed, as it is too bright for not being (also setting this as patch needs review to push it a bit ;)

senpai’s picture

Status: Needs review » Closed (fixed)

The original idea is sound, and seems like a cool thing to have, but since this issue was opened against 4.7, the demo site is now offline, and there is no patch written for this, I'm marking as 'closed'.

Should someone come along and submit a patch for this, be sure to mark it 'active' again.