PDA

View Full Version : Need help with a "Latest Links" module.


neverstop
11-13-2007, 11:46 PM
Hi,

I have this module installed: http://www.vbadvanced.com/forum/showthread.php?t=18416. I am trying to add the category's description (from adv_links_categories). The category's title is already being pulled from the adv_links_categories table so I think the tweaking should be relatively minor but I cannot figure it out, I don't know how to get around the fact there is already a "description" (the actual link description).

Here is the code:
$getlinks = $vbulletin->db->query("
SELECT $votequery links.*, links_categories.title FROM " . TABLE_PREFIX . "adv_links AS links
LEFT JOIN " . TABLE_PREFIX . "adv_links_categories AS links_categories ON (links.catid = links_categories.catid)
WHERE links.valid = 1 AND links.suspended = 0 $privcats
ORDER BY $orderby
LIMIT $limit
");
require_once(DIR . '/includes/class_bbcode.php');
while ($link = $vbulletin->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($vbulletin->options['dateformat'], $link['dateline'], true);
$link['time'] = vbdate($vbulletin->options['timeformat'], $link['dateline'], true);
$link['posts'] = number_format($link['posts']);
$link['replies'] = number_format($link['replies']);
$link[votenum] = number_format($link['votenum']);

$link['truerating'] = $link['votenum'] ? vb_number_format($link['votetotal'] / $link['votenum'], 2) : 0;
$link['roundrating'] = round($link['truerating']);
$parser =& new vB_BbCodeParser($vbulletin, fetch_tag_list());
$link['description'] = $parser->do_parse($link['description'], false, true, true, true, false, false);

$getbgrow = exec_switch_bg();
eval('$linkbits .= "' . fetch_template('adv_portal_linkbits') . '";');
}

So basically I want to be able to add $link['catdesc'] to my template and have it show the category description the same way $link['catname'] shows the category title.

Cheers,
Ian

neverstop
11-14-2007, 03:59 AM
Also, is it possible to join the custom field table to the query so i can use "$link['fieldx']" in the template?

Cheers

Our Sponsors
 

Brian
11-14-2007, 09:18 AM
$getlinks = $vbulletin->db->query("
SELECT $votequery links.*, links_categories.description AS catdesc, cfields.*, links_categories.title
FROM " . TABLE_PREFIX . "adv_links AS links
LEFT JOIN " . TABLE_PREFIX . "adv_links_categories AS links_categories ON (links.catid = links_categories.catid)
LEFT JOIN " . TABLE_PREFIX . "adv_links_cfield_entries AS cfields ON (links.linkid = cfields.lid)
WHERE links.valid = 1 AND links.suspended = 0 $privcats
ORDER BY $orderby
LIMIT $limit
");