vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Make the current forum's name to appear(inside a template) (https://vborg.vbsupport.ru/showthread.php?t=216809)

pierians 06-22-2009 02:06 PM

Make the current forum's name to appear(inside a template)
 
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
Quote:

<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 03: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 03: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
Quote:

<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[bburl]/$stylevar[imgdir_button]/collapse_thead$vbcollapse[collapseimg_latest_attachments].gif" alt="" style="border: 0px" /></a>
</if>
<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 04: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 04:47 PM

Code:

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.

Code:

$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 04: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 05: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 05: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 05:08 PM

Ok i got it.

Because my Sql is rusty could you please provide me the correct code?

--------------- Added [DATE]1245698588[/DATE] at [TIME]1245698588[/TIME] ---------------

Ok i made it

Code:

$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 07:04 PM

Then in your select, say "f.title as ftitle" and then you would use "$array[$i][ftitle] = $rows['ftitle']", etc.


All times are GMT. The time now is 11:01 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03001 seconds
  • Memory Usage 1,748KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_code_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete