The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
How can I create Friends widget on the home page
Hello,
I need to create a widget on the home page that shows my friends like the widget on my profile. But I don't know how. Can anyone help me with this I just need to know the code that I can use on the widget to show my friends (Maybe limit the friends widget to show 6 friends only). I attached an image for the widget that I want to create one like it on the home page. Thanks a lot, |
#2
|
|||
|
|||
You could show up to 6 random friends like this:
Code:
global $vbulletin; $friends = $vbulletin->db->query_read_slave("SELECT user.*, userlist.type, userlist.friend FROM " . TABLE_PREFIX . "userlist AS userlist INNER JOIN " . TABLE_PREFIX . "user AS user ON (user.userid = userlist.relationid) WHERE userlist.userid = " . $vbulletin->userinfo['userid'] . " AND userlist.type='buddy' AND userlist.friend='yes' ORDER BY RAND() LIMIT 6 "); while ($friend = $vbulletin->db->fetch_array($friends)) { $output .= '<a href="member.php?u=' . $friend['userid'] . '">' . $friend['username'] . "</a><br />\r\n"; } |
#3
|
|||
|
|||
Thank you kh99 for your reply. But could you please teach me how to add your code in widget on the home page. Because I created a new HTML static widget and I paste your code into the widget but when I browsed the Home Page I found the widget shows your code as it is. So I replaced the HTML Static widget with PHP Direct Execution widget and when I browsed the Home Page I found the date of today showing up only in the widget.
Can you help me please. I don't know where's the problem. |
#4
|
|||
|
|||
The php direct execution widget should work. By default the "configure" text area has a sample line of code that displays the date. You need to make sure you remove that.
|
#5
|
|||
|
|||
Hi kh99,
You are absolutely right. I used php direct execution widget and I replaced the code for the date with your code and the widget works fine now. But is there any chance to list the names of my friends with their profile photos as in the friends widget in my profile (see the attached image in the first post)?? |
#6
|
|||
|
|||
I've started working on something like that. Hopefully it won't take too long (and hopefully I'll actually finish ).
|
#7
|
|||
|
|||
A million thanks to you Kh99. I wish you best of luck with the developing of this widget.
I'll keep monitoring your progress with joy! |
#8
|
|||
|
|||
very good !
|
#9
|
||||
|
||||
To show all your friends online in a widget you would use this:
Code:
global $vbulletin; if (!$vbulletin->userinfo['userid']) { } else { $datecut = TIMENOW - $vbulletin->options['cookietimeout']; $buddys = $vbulletin->db->query_read(" SELECT user.username, user.userid, user.lastactivity FROM " . TABLE_PREFIX . "userlist AS userlist LEFT JOIN " . TABLE_PREFIX . "user AS user ON(user.userid = userlist.relationid) WHERE userlist.userid = {$vbulletin->userinfo['userid']} AND userlist.relationid = user.userid AND type = 'buddy' AND user.lastactivity > $datecut ORDER BY username ASC "); $output = ''; while ($buddy = $vbulletin->db->fetch_array($buddys)) { $output .= ' <a href="member.php?' . $buddy['userid'] . '"> ' . $buddy['username'] . '</a> '; } if ($output != '') { /*$output = '<font color=#ff0000>Friends Online:</font>' . $output;*/ $template_hook['navtab_end'] .= ' '; } } |
Благодарность от: | ||
evelynpriscilla |
#10
|
|||
|
|||
lol, I guess I never did finish this. Anyway, I haven't tried it but I think something like this should work:
Code:
global $vbulletin; if (!$vbulletin->userinfo['userid']) { } else { $datecut = TIMENOW - $vbulletin->options['cookietimeout']; $buddys = $vbulletin->db->query_read(" SELECT user.username, user.userid, user.lastactivity, user.usergroupid, user.displaygroupid FROM " . TABLE_PREFIX . "userlist AS userlist LEFT JOIN " . TABLE_PREFIX . "user AS user ON(user.userid = userlist.relationid) WHERE userlist.userid = {$vbulletin->userinfo['userid']} AND userlist.relationid = user.userid AND type = 'buddy' AND user.lastactivity > $datecut ORDER BY username ASC "); $output = ''; $separator = ''; while ($buddy = $vbulletin->db->fetch_array($buddys)) { fetch_musername($buddy); $output .= $separator . '<a href="member.php?' . $buddy['userid'] . '">' . $buddy['musername'] . '</a> '; $separator = ', '; } if ($output != '') { /*$output = '<font color=#ff0000>Friends Online:</font>' . $output;*/ $template_hook['navtab_end'] .= ' '; } } |
Благодарность от: | ||
CAG CheechDogg |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|