View Full Version : CMPS Module - Latest or Hot Links
Brian
07-23-2004, 01:42 PM
For all of those running both the CMPS and the links directory, here's a module that will allow you to display the latest, highest rated, most viewed, or most replied to links on your CMPS pages. To install, first add these two templates:
adv_portal_latestlinks
<table align="center" border="0" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" class="tborder" width="100%">
<tr>
<td class="tcat"><span class="smallfont"><strong>$vba_options[portal_blockbullet] $mods[title]</strong></span></td>
</tr>
$linkbits
</table>
<br />
adv_portal_linkbits
<tr>
<td class="$getbgrow">
<div><a href="$linkurl/showlink.php?$session[sessionurl]do=showdetails&l=$link[linkid]">$link[name]</a></div>
<div class="smallfont">
$vbphrase[by]
<if condition="$link['userid']"><a href="$vboptions[bburl]/member.php?$session[sessionurl]u=$link[userid]">$link[username]</a>
<else />
$vbphrase[guest]
</if><br />
$link[date] <span class="time">$link[time]</span><br />
<a href="$linkurl/browselinks.php?$session[sessionurl]c=$link[catid]">$link[catname]</a><br />
$link[posts] $vbphrase[replies], $link[views] $vbphrase[views]
</div>
</td>
</tr>
Then download the latestlinks.php attachement below. In the first few lines of the file you will see a place to set the different options. Once you have them set as you would like, upload the file to your /forum/modules directory.
Now add a new module with the following information:
Module Title: Latest Links (or whatever you would like to call this module on your CMPS)
File to Include: latestlinks.php
Templates Used: adv_portal_latestlinks, adv_portal_linkbits
Save the module and you're done. :)
ricoche
07-23-2004, 11:23 PM
Thank you! This is great.
- Jim
pdatotaal
08-05-2004, 12:02 AM
Would be nice if you can choice the links Category in the (extra) pages. Like you can do with News, Latest Threads and Poll ! But it works great btw!
hpwilhelm
08-26-2004, 05:43 PM
Thanks Brian! :)
Just want to add that if this module is active in the 'linksdirectory' page of the CMPS you get a MySQL error. So don't select 'update all pages' if you've got the Linksdirectory integrated with the CMPS. (Or remember to deselect it from the 'linksdirrectory' settings page... :p).
- HP
Nordinho
09-03-2004, 04:51 PM
Heya,
Is it possible to display a small linkdescription (like the first 15 words of the description) and the rating of the link(if rated) in this latest links block as well?? I've played with it a little, but I didn't came any further then a red cross, where the rating should be. Any help is appreciated!!
Greets Nordinho,
socals
09-04-2004, 09:15 PM
If you look at the file Brian posted, it supports 4 different views. It just happens to default to the Recent Links query. I wanted it to randomly pick a view, so here's how to do it:
Find "$order = 2;" and comment it out (as shown commented out):
// The order you would like to pull the links in.
// Enter 1 for newest, 2 for most viewed, 3 for most comments, 4 for highest rated
//$order = 2;
Now above it add:
function make_seed()
{
list($usec, $sec) = explode(' ', microtime());
return (float) $sec + ((float) $usec * 100000);
}
srand(make_seed());
$randval = rand();
$order = rand(1, 4);
Update the switch statement a few lines down with:
switch($order)
{
case 2:
$orderby = 'views DESC';
$modtitle = 'Top Links';
break;
case 3:
$orderby = 'posts DESC';
$modtitle = 'Top Replied Links';
break;
case 4:
$votequery = 'IF(votenum >= ' . $vboptions['showvotes'] . ', votenum, 0) AS votenum, IF(votenum >= ' . $vboptions['showvotes'] . ' AND votenum> 0, votetotal / votenum, 0) AS voteavg,';
$modtitle = 'Top Rated Links';
$orderby = 'voteavg DESC, votenum DESC';
break;
default:
$orderby = 'dateline DESC';
$modtitle = 'Latest Links';
}
I just added $modtitle to the switch elements.
Now go into the adv_portal_latestlinks template and search and replace $mods[title] with $modtitle.
That's it.
A random view will now be displayed.
Nordinho
09-05-2004, 07:51 PM
Hmmm, thinking about this module again...is it possible to display the whole 'newest 10 links' block from the links mainpage on the portal homepage??
Greets Nordinho,
Nordinho
09-07-2004, 10:36 AM
Anyone?? :)
Nordinho
09-10-2004, 11:04 AM
Any pointers are appreciated :)
Greets,
Nordinho
09-17-2004, 01:53 PM
I tried creating a new module with the content of some of the link templates and I created a new linkbit file, but as you might have guessed, it doesn't work...any other idea's?? I really would like to display the content of the newest 10 links from the linkpage on the frontpage as a module!!
Greets Nordinho,
58sniper
09-26-2004, 10:04 AM
Has anyone figured out a valid XHTML way of doing this? This method breaks validation horribly.
nexia
09-26-2004, 12:55 PM
Has anyone figured out a valid XHTML way of doing this? This method breaks validation horribly.
it's always the same... vBulletin is not built to suite the XHTML compliance in any way, it use tables all the way around... but you can deal with it via css and divs if you really need it to be compliant!
58sniper
09-26-2004, 12:58 PM
it's always the same... vBulletin is not built to suite the XHTML compliance in any way, it use tables all the way around... but you can deal with it via css and divs if you really need it to be compliant!
For the most part, vBulletin is completely xHTML compliant.
tfw2005
10-05-2004, 04:10 PM
Any way to use 2 modules at the same time? I renamed the module to latestlinks1.php, and installed it a second time, 1 for new, one for most popular, and its calling the first module blocks content into the second modules block, THEN listing the second modules content.
Im figuring its the way the call is, not sure how to fix it, if even possible.
Brian
10-06-2004, 01:36 PM
Open the file and look for:
eval('$home[$mods[\'modid\']][\'content\'] = "' . fetch_template('adv_portal_latestlinks') . '";');
Right above that, add:
$DB_site->free_result($getlinks);
unset($link);
See if that helps. :)
tfw2005
10-07-2004, 02:50 PM
I added it to latestlinks.php and latestlinks1.php, didnt work. Added it to just latestlinks1.php, didn't work. Added it to just latestlinks.php, didn't work.
Would creating a second set of templates in the CP and relinking to those do anything? Doesn't seem like it would, but I dont know for sure.
Images of what is happening are attached, turned off to all but admins right now.
Brian
10-07-2004, 03:23 PM
Strange... Would you mind submitting a support ticket so I can have a look?
Debbi
10-09-2004, 07:41 PM
I know this is picky but I'm a freaky perfectionist LOL. How would I remove this space to make it look like the block above it? I know it's a template thing but I suck horribly in that area. Any help would be greatly appreciated. Thanks!
Brian
10-10-2004, 11:12 AM
Change the 'adv_portal_latestlinks' template to the new one in the first post (I didn't realize I had a mistake in the code). ;)
Debbi
10-10-2004, 11:15 AM
Brian you are my hero. Thank you!
surfdude
11-18-2004, 07:18 AM
Thanks Brian for this mod, it works great.
Also, cheers socals for random link display, as I wanted this feature.
Torqued
12-03-2004, 11:50 PM
I'm running this module and installed Erwin's MicroStats hack and it reports these two links templates as uncached. How do I fix this?
Uncached templates: adv_portal_latestlinks (1)
Uncached templates: adv_portal_linkbits (10)
Brian
12-04-2004, 03:31 PM
Now add a new module with the following information:
Module Title: Latest Links (or whatever you would like to call this module on your CMPS)
File to Include: latestlinks.php
Templates Used: adv_portal_latestlinks, adv_portal_linkbits
.
Torqued
12-04-2004, 05:32 PM
Thanks, Brian. I had left out the comma between those templates in the module settings.
yinyang
01-09-2005, 10:13 PM
I would super super appreciate it if someone could make an alternate template to be used in the center section of the cmps. Thus, the hot links would look (format wise) exactly like the last topics.
Please?
yinyang
01-11-2005, 02:32 AM
anyone?
I've installed this module and it displays the links fine in CMPS side bar but whenever I try to see the links page, I get a mysql error.
I read hpwilhelm's post above and created a new page just for CMPS and Links but it doesn't change anything. If the module is active in any page, I always get the same error.
Any ideas?
Database error in vBulletin 3.0.5:
Invalid SQL:
SELECT links.*, links_categories.title FROM vb3_links AS links
LEFT JOIN vb3_links_categories AS links_categories ON (links.catid = links_categories.catid)
WHERE valid = 1 AND suspended = 0 AND links.catid NOT IN ()
ORDER BY dateline DESC
LIMIT 5
mysql error: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near ')
ORDER BY dateline DESC
LIMIT 5' at line 3
mysql error number: 1064
yinyang
01-11-2005, 04:53 AM
since i'm about to launch my site soon and most everything forum and link related needs to go into the center column, i went ahead and tried redoing Brian's template so it sort of looks like the Latest Forum Topics. This way, the formatting is similar throughout.
please let me know if there's anything wrong or weird.
my setting is #2, or most viewed.
adv_portal_latestlinks
<table align="center" border="0" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" class="tborder"width="100%">
<tr>
<td colspan="6" class="tcat"><span class="smallfont"><strong>$vba_options[portal_blockbullet] <a href="links/">$mods[title]</a></strong></span></td>
</tr>
<tr>
<td class="thead" width="5"> </td>
<td class="thead" width="100%"><span class="smallfont">Title, Username</span></td>
<td align="center" class="thead" nowrap="nowrap" width="25%"><span class="smallfont">Post</span></td>
<td class="thead" width="15"><span class="smallfont">$vbphrase[replies]</span></td>
<td class="thead" width="15"><span class="smallfont">$vbphrase[views]</span></td>
<td align="center" class="thead" width="10%"><span class="smallfont">Category</td>
</tr>
$linkbits
</table>
<br />
adv_portal_linkbits
<tr>
<td class="alt2"> </td>
<td class="alt1"><a href="$linkurl/showlink.php?$session[sessionurl]do=showdetails&l=$link[linkid]"><b>$link[name]</b></a><br/>
$link[username]</a></td>
<td class="alt2"><div class="smallfont" style="text-align:right; white-space:nowrap">$link[date] <span class="time">$link[time]</span><br />
<div></td>
<td align="center" class="alt1"><span class="smallfont">$link[posts]</span></td>
<td align="center" class="alt2"><span class="smallfont">$link[views]</span></td>
<td align="center" class="alt2"><span class="smallfont"><a href="$linkurl/browselinks.php?$session[sessionurl]c=$link[catid]">$link[catname]</a><span></td>
</tr>
again, i'm not a coder and not positive this is right, but it works thus far for me *crosses fingers*.
This is a great modification thanks :)
is there a way to show this block side by side in a center block?
Vevina
02-28-2005, 09:50 AM
Installed "Very Easy" :)
Jason McConnell
03-23-2005, 12:46 PM
I've installed this module and it displays the links fine in CMPS side bar but whenever I try to see the links page, I get a mysql error.
I read hpwilhelm's post above and created a new page just for CMPS and Links but it doesn't change anything. If the module is active in any page, I always get the same error.
Any ideas?
Database error in vBulletin 3.0.5:
Invalid SQL:
SELECT links.*, links_categories.title FROM vb3_links AS links
LEFT JOIN vb3_links_categories AS links_categories ON (links.catid = links_categories.catid)
WHERE valid = 1 AND suspended = 0 AND links.catid NOT IN ()
ORDER BY dateline DESC
LIMIT 5
mysql error: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near ')
ORDER BY dateline DESC
LIMIT 5' at line 3
mysql error number: 1064
I just got the same error :confused:
EDIT: Just disabled the module on my links index and it works just fine again :D
ncangler
04-10-2005, 05:38 PM
I modified this a bit more and I'm trying to get the full link title (it only shows partial right now) and I want the user and date posted under the title (as in the main links display). You can see what I've been able to get working in the attached image 1. Image 2 is what I'd like it to look like.
Here is the code I've plugged in the linkbits template:
tr>
<td class="alt2"> </td>
<td class="alt1"><a href="$linkurl/showlink.php?$session[sessionurl]do=showdetails&l=$link[linkid]"><b>$link[name]</b></a>
<br/>
<fieldset class="fieldset"><legend><phrase 1="$link[username]" 2="$link[updatedate]" 3="$link[updatetime]" 4="$vboptions/member.php?$session[sessionurl]u=$link[userid]">
<if condition="$link['userid']">
$vbphrase[by_username_on_date]
<else />
$vbphrase[by_guest_on_date]
</if>
</phrase></legend>$link[description]</fieldset></td>
<td align="center" class="alt2"><span class="smallfont"><a href="$linkurl/browselinks.php?$session[sessionurl]c=$link[catid]">$link[catname]</a><span></td>
</tr>
[b]Here is the code I've put in for the latestlinks:
<table align="center" border="0" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" class="tborder"width="100%">
<tr>
<td colspan="6" class="tcat"><span class="smallfont"><strong>$vba_options[portal_blockbullet] <a href="links/">$mods[title]</a></strong></span></td>
</tr>
<tr>
<td class="thead" width="5"> </td>
<td class="thead" width="100%"><span class="smallfont">Link Name and Description</span></td>
<td align="center" class="thead" width="10%"><span class="smallfont">Category</td>
</tr>
$linkbits
</table>
<br />
Any help in tweaking this is most appreciated!
Darax The Good
05-10-2005, 12:45 AM
Would be nice if you can choice the links Category in the (extra) pages. Like you can do with News, Latest Threads and Poll ! But it works great btw!
Yes, this would be nice... has anyone solved this yet?
Darax The Good
05-10-2005, 01:18 AM
I think I've almost got it :)
Brian, your code is a thing of beauty. You should be commended.
Darax The Good
05-10-2005, 02:00 AM
Yeah, I got it working...
a couple database hacks, which I'm sure that brian can make better and a teensy edit to his PHP file and it works.
Here's what I did:
I added a row to the adv_settinggroup
grouptitle=adv_portal_links
displayorder = 7 (this was arbitrary)
and I added a row to the adv_setting:
varname=portal_links_linkid
grouptitle=adv_portal_links
value=0
defaultvalue=0
optioncode=
displayorder=1
then in the latestlinks.php find:
$getlinks = $DB_site->query("
SELECT $votequery links.*, links_categories.title FROM " . TABLE_PREFIX . "links AS links
LEFT JOIN " . TABLE_PREFIX . "links_categories AS links_categories ON (links.catid = links_categories.catid)
WHERE valid = 1 AND suspended = 0 $privcats
ORDER BY $orderby
LIMIT $limit
");
and replace with
$getlinks = $DB_site->query("
SELECT $votequery links.*, links_categories.title FROM " . TABLE_PREFIX . "links AS links
LEFT JOIN " . TABLE_PREFIX . "links_categories AS links_categories ON (links.catid = links_categories.catid)
WHERE valid = 1 AND suspended = 0 AND links.catid IN($vba_options[portal_links_linkid]) $privcats
ORDER BY $orderby
LIMIT $limit
");
notice I'm just forcing it to only use the categories specified by the hacks we did in the db above. Now when you edit your page there will be a new text field at the bottom, enter the link categories in just as you would the news or poll categories.
You may worship me later.
RetroDreams
08-28-2005, 12:05 PM
Is this not functional with 3.5? When I attempt to run it, I get the following error:
Fatal error: Call to a member function on a non-object in /home/dukecoun/public_html/indy/forums/modules/latestlinks.php on line 56
RetroDreams
08-31-2005, 02:44 AM
Anyone out there?
DougM
09-03-2005, 11:37 PM
Is this not functional with 3.5? When I attempt to run it, I get the following error: Glad I saw your post. I too wish to use this with 3.5. I look forward to hearing any comments on the subject.
AndyA
09-25-2005, 06:48 AM
Thanks for that.
I now have this installed but the links module isn't collapseable, can anyone advise ?
My site (http://www.throttlejockey.co.uk/forum/cmps_index.php)
Andy
How can we use this with 3.5 ?
terrymason
01-10-2006, 10:43 AM
I'd like to have a new version too!
Lance Carbuncle
01-12-2006, 02:58 PM
Will this work with 3.5x? any news on when it will be upgraded if so?
Thanks, Allen
Benjamini
02-20-2006, 01:41 PM
Will this work with 3.5x? any news on when it will be upgraded if so?
Thanks, Allen
same question here :)
IndyWebDesign
02-20-2006, 11:57 PM
Here is a modified version I did to work with vb 3.5.3 and CMPS 2.1.0.
I have it working here:
http://www.rchangout.com
Benjamini
02-21-2006, 05:41 PM
Here is a modified version I did to work with vb 3.5.3 and CMPS 2.1.0.
I have it working here:
http://www.rchangout.com
thank you very much!!!
edit:
The file you have uploaded is not a valid module file.
whats wrong? i have a vb 3.5.2 & CMPS 2.0.0
Benjamini
02-21-2006, 06:07 PM
Here are the manually from your .module.
now it works, but i think there is a littele problem with the template or any other thing...
http://img462.imageshack.us/img462/1245/ohnetitel18pj.gif
"title" "Random Links"
"identifier" "latestlinks"
"filename" "latestlinks.php"
"templatelist" "adv_portal_latestlinks, adv_portal_linkbits"
"adv_portal_latestlinks"
<table align="center" border="0" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" class="tborder" width="100%">
<thead>
<tr>
<td class="tcat">
<a style="float:$stylevar[right]" href="#top" onclick="return toggle_collapse('latestlinks')"><img id="collapseimg_latestlinks"
src="$stylevar[imgdir_button]/collapse_tcat$collapseimg_latestlinks.gif" alt="" border="0" /></a>
<span class="smallfont"><strong>$vba_style[portal_blockbullet] $mods[title]</strong></span></td>
</tr>
</thead>
<tbody id="collapseobj_latestlinks" style="$collapseobj_latestlinks">
$linkbits
</table>
<br />
"adv_portal_linkbits"
<tr>
<td class="$getbgrow">
<div><a href="$linkurl/showlink.php?$session[sessionurl]do=showdetails&l=$link[linkid]">$link[name]</a></div>
<div class="smallfont">
$vbphrase[by]
<if condition="$link['userid']"><a href="$vboptions[bburl]/member.php?$session[sessionurl]u=$link[userid]">$link[username]</a>
<else />
$vbphrase[guest]
</if><br />
$link[date] <span class="time">$link[time]</span><br />
<a href="$linkurl/browselinks.php?$session[sessionurl]c=$link[catid]">$link[catname]</a><br />
$link[posts] $vbphrase[replies], $link[views] $vbphrase[views]
</div>
</td>
</tr>
latestlinks.php
<?php
// ++=========================================================================++
// || vBadvanced CMPS 1.0.0 - Latest Links for vBa Links Directory ||
// || © 2003-2004 vBadvanced.com & PlurPlanet, LLC - All Rights Reserved ||
// || This file may not be redistributed in whole or significant part. ||
// || http://vbadvanced.com ||
// ++ ========================================================================++
// || Modified to work with CMPS 2.1.0 and vB 3.5.3 ||
// || Added option for Random Links ||
// ++ ========================================================================++
// The order you would like to pull the links in.
// Enter 1 for newest, 2 for most viewed, 3 for most comments, 4 for highest rated, 5 for random
$order = 5;
// Enter the number of links you would like to display here
$limit = 5;
// The URL to your links directory with NO trailing slash '/'
$linkurl = 'http://www.yoursite.com/links';
// Maximum characters of the links name before the rest will be replaced with '...'
// Set this to 0 to disable it.
$maxnamechars = 0;
// No further editing necessary
switch($order)
{
case 2:
$orderby = 'views DESC';
break;
case 3:
$orderby = 'posts DESC';
break;
case 4:
$votequery = 'IF(votenum >= ' . $vboptions['showvotes'] . ', votenum, 0) AS votenum, IF(votenum >= ' . $vboptions['showvotes'] . ' AND votenum> 0, votetotal / votenum, 0) AS voteavg,';
$orderby = 'voteavg DESC, votenum DESC';
break;
case 5:
$orderby = 'RAND()';
break;
default:
$orderby = 'dateline DESC';
}
// Get private directories
if ($catinfo = unserialize($datastore['links_d_cache']))
{
$privcatids = array();
foreach ($catinfo as $cats)
{
if ($cats['private'])
{
$privcatids[] = $cats['catid'];
}
}
$privcats = 'AND links.catid NOT IN (' . implode(',', $privcatids) . ')';
}
$getlinks = $db->query("
SELECT $votequery links.*, links_categories.title FROM " . TABLE_PREFIX . "links AS links
LEFT JOIN " . TABLE_PREFIX . "links_categories AS links_categories ON (links.catid = links_categories.catid)
WHERE valid = 1 AND suspended = 0 $privcats
ORDER BY $orderby
LIMIT $limit
");
while ($link = $db->fetch_array($getlinks))
{
$link['catname'] = stripslashes($link['title']);
$link['name'] = fetch_trimmed_title(stripslashes($link['name']), $maxnamechars);
$link['username'] = stripslashes($link['username']);
$link['date'] = vbdate($vboptions['dateformat'], $link['dateline']);
$link['time'] = vbdate($vboptions['timeformat'], $link['dateline']);
$link['posts'] = number_format($link['posts']);
$link['replies'] = number_format($link['replies']);
$getbgrow = exec_switch_bg();
eval('$linkbits .= "' . fetch_template('adv_portal_linkbits') . '";');
}
$collapseobj_latestlinks = $vbcollapse['collapseobj_latestlinks'];
$collapseimg_latestlinks = $vbcollapse['collapseimg_latestlinks'];
eval('$home[$mods[\'modid\']][\'content\'] = "' . fetch_template('adv_portal_latestlinks') . '";');
?>
Benjamini
02-23-2006, 08:29 AM
... nobody can help? here are a lot of vbadvanced users and nobody got a running hotest link module?
Torqued
03-03-2006, 03:46 PM
Anyone else figure this one out?
vBulletin® v3.8.4, Copyright ©2000-2012, Jelsoft Enterprises Ltd.