Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 06-22-2009, 03:06 PM
pierians pierians is offline
 
Join Date: May 2008
Posts: 45
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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
Reply With Quote
  #2  
Old 06-22-2009, 04:49 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You can do that if the variable is available. You've said nothing about what template you are trying to do this in.
Reply With Quote
  #3  
Old 06-22-2009, 04:57 PM
pierians pierians is offline
 
Join Date: May 2008
Posts: 45
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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 />
Reply With Quote
  #4  
Old 06-22-2009, 05:27 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #5  
Old 06-22-2009, 05:47 PM
pierians pierians is offline
 
Join Date: May 2008
Posts: 45
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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?
Reply With Quote
  #6  
Old 06-22-2009, 05:54 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #7  
Old 06-22-2009, 06:00 PM
pierians pierians is offline
 
Join Date: May 2008
Posts: 45
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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?
Reply With Quote
  #8  
Old 06-22-2009, 06:06 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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).
Reply With Quote
  #9  
Old 06-22-2009, 06:08 PM
pierians pierians is offline
 
Join Date: May 2008
Posts: 45
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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?
Reply With Quote
  #10  
Old 06-22-2009, 08:04 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 03:41 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.05114 seconds
  • Memory Usage 2,261KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (3)bbcode_code
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete