View Full Version : Top 5 Newest User Notes Help
DrOwn
07-01-2005, 05:12 AM
I am trying to make a Top 5 Newest User Notes block.
Here is the modules/usernote.php code
<?php
$usernote = $DB_site->query_first("SELECT userid, username FROM ".TABLE_PREFIX."usernote ORDER BY dateline DESC LIMIT 5");
$userid = $usernote[userid];
$username = $usernote[username];
eval('$home[$mods[\'modid\']][\'content\'] = "' . fetch_template('adv_portal_usernotes') . '";');
?>
Here is the Template ( without the block tables ect ect )
<a href=$vboptions[bburl]/member.php?u=$usernote[userid]">
$usernote[username]</a>
Anyone see what I am doing wrong ?
Brian
07-01-2005, 10:52 AM
<?php
$usernotes = $DB_site->query("SELECT userid, username FROM ".TABLE_PREFIX."usernote ORDER BY dateline DESC LIMIT 5");
while($usernote = $DB_site->fetch_array($usernotes))
{
eval('$home[$mods[\'modid\']][\'content\'] .= "' . fetch_template('adv_portal_usernotes') . '";');
}
?>
DrOwn
07-01-2005, 04:01 PM
Thanks Brian, I changed the code to sort by usernoteid. If you look at the screenshot you will see the table repeats 5 times and note the latest user "Strabo" has not even posted a usernote so I dont know why his name comes up?
<?php
$usernotes = $DB_site->query("SELECT userid, username FROM ".TABLE_PREFIX."usernote ORDER BY usernoteid DESC LIMIT 5");
while($usernote = $DB_site->fetch_array($usernotes))
{
eval('$home[$mods[\'modid\']][\'content\'] .= "' . fetch_template('adv_portal_usernotes') . '";');
}
?>
Template change as well.
<a href=$vboptions[bburl]/usernote.php?u=$userid>
$username</a>
Any ideas? do you know how to pull the first say 10 letters from the message field to alt" " over the user name and sort the date to output a time in the dateline field just to make it more interesting.
I think this could be a nice addon for vba as the usernotes option is a bit hidden in vbulletin from a users view.
Brian
07-01-2005, 06:59 PM
<a href=$vboptions[bburl]/usernote.php?u=$userid>
$username</a>
That's the entire content you have for your 'adv_portal_usernotes' template? I don't see how you would be getting that as the output for the module if so...
DrOwn
07-02-2005, 05:43 AM
This is the template.
<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center"><thead><tr><td class="thead">
<a style="float:$stylevar[right]" href="#" onclick="return toggle_collapse('usernote')"><img id="collapseimg_usernote" src="$stylevar[imgdir_button]/collapse_thead$vbcollapse[collapseimg_usernote].gif" alt="Collapse/Expand" border="0" /></a>$vba_options[portal_blockbullet] $mods[title]</td></tr></thead>
<tbody id="collapseobj_usernote" style="$vbcollapse[collapseobj_usernote]">
<tr><td class="alt1" align="center">
<a href=$vboptions[bburl]/usernote.php?u=$userid>$username</a>
</td></tr></tbody></table>
Brian
07-02-2005, 10:45 AM
Try this for the file:
<?php
$usernotes = $DB_site->query("SELECT userid, username FROM " . TABLE_PREFIX . "usernote ORDER BY usernoteid DESC LIMIT 5");
while($usernote = $DB_site->fetch_array($usernotes))
{
$unotes .= '<a href="' . $vboptions['bburl'] . '/usernote.php?u=' . $usernote['userid'] . '">' . $usernote['username'] . '</a>';
}
eval('$home[$mods[\'modid\']][\'content\'] = "' . fetch_template('adv_portal_usernotes') . '";');
?>
And this for the template:
<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center"><thead><tr><td class="thead">
<a style="float:$stylevar[right]" href="#" onclick="return toggle_collapse('usernote')"><img id="collapseimg_usernote" src="$stylevar[imgdir_button]/collapse_thead$vbcollapse[collapseimg_usernote].gif" alt="Collapse/Expand" border="0" /></a>$vba_options[portal_blockbullet] $mods[title]</td></tr></thead>
<tbody id="collapseobj_usernote" style="$vbcollapse[collapseobj_usernote]">
<tr><td class="alt1" align="center">
$unotes
</td></tr></tbody></table>
ibrahimm
07-19-2005, 10:55 AM
Used the last template and code. Its not working. Attached what i get.
vBulletin® v3.7.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.