View Full Version : Make the current forum's name to appear(inside a template)
pierians
06-22-2009, 03:06 PM
Hello, is there anyway that i can print on the screen the name of the current forum i am serfing?
I need this to be done from within a template.
I use this code as a header of a table
<div>$vbphrase[latest_attachments_latest] $vboptions[latest_attachments_max] <strong>Uploads</strong></div>
This prints: Latest 6 Uploads
I want this to print:
Latest 6 Uploads In "The name of the current forum"
So if i am serfing a forum named "News" i want this to print
Latest 6 Uploads In News
Lynne
06-22-2009, 04:49 PM
You can do that if the variable is available. You've said nothing about what template you are trying to do this in.
pierians
06-22-2009, 04:57 PM
This template is called "lattest_x_attachments_forumdisplay" and i call this template inside forumdisplay.
Is there other info that i could provide you?
This is the "lattest_x_attachments_forumdisplay" template
<br>
<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" style="border:0px" width="100%" align="center">
<thead>
<tr>
<td class="thead" style="text-align:justify" colspan="$vboptions[latest_attachments_maxperrow]">
<if condition="$vboptions['latest_attachments_collapse']">
<a style="float:$stylevar[right]" href="#top" onclick="return toggle_collapse('latest_attachments')"><img id="collapseimg_latest_attachments" src="$vboptions/$stylevar[imgdir_button]/collapse_thead$vbcollapse[collapseimg_latest_attachments].gif" alt="" style="border: 0px" /></a>
</if>
[B]<div>$vbphrase[latest_attachments_latest] $vboptions[latest_attachments_max] <strong>Uploads</strong></div>
</td>
</tr>
</thead>
<if condition="$vboptions['latest_attachments_collapse']">
<tbody id="collapseobj_latest_attachments" style="$vbcollapse[collapseobj_latest_attachments]">
</if>
<if condition="$thumbnails">
<tr>$thumbnails</tr>
<else />
<tr>
<td class="alt1" align="center">
$vbphrase[no_attachments_in_this_forum]
</td>
</tr>
</if>
<if condition="$vboptions['latest_attachments_collapse']">
</tbody>
</if>
</table>
<br />
Lynne
06-22-2009, 05:27 PM
What hook location are you using to eval that template? Go find that hook in the code. Then look above that code and see what variables are available to you for use.
pierians
06-22-2009, 05:47 PM
eval('$latest_x_attachments_forumdisplay = "' . fetch_template('latest_x_attachments_forumdisplay' ) . '";');
and the variables are
global $db, $vbulletin, $vbphrase, $latest_x_attachments;
The plugin has some queries in it.
$query = $vbulletin->db->query_read("
SELECT a.attachmentid, a.userid, p.username, a.dateline, a.filename, a.filesize, a.counter, p.postid, p.pagetext, t.threadid, t.title
FROM " . TABLE_PREFIX . "attachment AS a
LEFT JOIN " . TABLE_PREFIX . "post AS p ON (a.postid = p.postid)
LEFT JOIN " . TABLE_PREFIX . "thread AS t ON (p.threadid = t.threadid)
WHERE a.thumbnail_filesize > '0'
AND t.forumid = '" . $foruminfo['forumid'] . "'
$order");
What do i have to add in this query and how can i use at the template the variable i will add at the plugin?
Lynne
06-22-2009, 05:54 PM
That query doesn't grab the forumid at all. It references it in the where statement, but you don't have it in the select statement at all, so it's not available. You will probably have to JOIN on the forum table to get the forum title.
pierians
06-22-2009, 06:00 PM
ok let's say that i did this...
i put the forum's name at the select and include the forum table with an inner join...
how can i use it at the template?
Lynne
06-22-2009, 06:06 PM
You didn't show the line after the query that would provide me with the variable name to give you, so I don't know, but something like $variablename[title] probably (assuming the eval is within the while statement).
pierians
06-22-2009, 06:08 PM
Ok i got it.
Because my Sql is rusty could you please provide me the correct code?
--------------- Added 1245698588 at 1245698588 ---------------
Ok i made it
$query = $vbulletin->db->query_read("
SELECT a.attachmentid, a.userid, p.username, a.dateline, a.filename, a.filesize, a.counter, p.postid, p.pagetext, t.threadid, t.title, f.title
FROM " . TABLE_PREFIX . "attachment AS a
LEFT JOIN " . TABLE_PREFIX . "post AS p ON (a.postid = p.postid)
LEFT JOIN " . TABLE_PREFIX . "thread AS t ON (p.threadid = t.threadid)
LEFT JOIN " . TABLE_PREFIX . "forum AS f ON (f.forumid = t.forumid)
WHERE a.thumbnail_filesize > '0'
AND t.forumid = '" . $foruminfo['forumid'] . "'
$order");
$thumbnails = '';
while($i < $max && $rows = $db->fetch_array($query))
{
if($foruminfo['forumid'])
{
$i++;
$array[$i][attachmentid] = $rows['attachmentid'];
$array[$i][postid] = $rows['postid'];
$array[$i][thumbnail] = $rows['thumbnail'];
$array[$i][dateline] = $rows['dateline'];
$array[$i][filename] = $rows['filename'];
$array[$i][filesize] = $rows['filesize'];
$array[$i][userid] = $rows['userid'];
$array[$i][username] = $rows['username'];
$array[$i][title] = $rows['title'];
//$array[$i][title] = $rows['title'];
}
But there is already a variable called title...(that's why i made it comment)
How can i use it?
Lynne
06-22-2009, 08:04 PM
Then in your select, say "f.title as ftitle" and then you would use "$array[$i][ftitle] = $rows['ftitle']", etc.
pierians
06-22-2009, 09:23 PM
it worked!!!
thank you a lot!
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.