vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Php/mysql code in VBulletin templates (https://vborg.vbsupport.ru/showthread.php?t=250558)

deni_z 09-15-2010 02:52 PM

Php/mysql code in VBulletin templates
 
1 Attachment(s)
Hi everybody!

I want to make a modification to my forum. I don't want to bore you with all the details. For now I added a "my_keyword" to thread table in the database, and now I just want to display it next to the thread title.

In forumhome_forumbit_level2_post I did this:

Code:

<td class="alt1Active" align="$stylevar[left]" id="f$forum[forumid]">
                <div>
$rr = $vbulletin->$db->query_first("SELECT oras FROM af_thread WHERE userid = " . $forum[forumid] . ");

                        <a href="forumdisplay.php?$session[sessionurl]f=$forum[forumid]"><strong>$forum[title] - $rr </strong>

and the result is in the picture...

So, my question is: How to make it work?

kh99 09-15-2010 07:10 PM

vBulletin limits what you can do in a template, I guess the idea is that you could let a "designer" (or whatever you want to call it) work on the appearance of the site without doing anything "dangerous". So for most coding beyond a simple if condition you need to create a plugin. (I think you might be able to do a little more in a template in vB4, but I don't remember for sure).

Anyway, you can just copy your line of code to the plugin, the problem is chooing a hook location. You pretty much have to go to the source code and figure out where your template is being evaluated, then find a hook location that gets eval'd before that. In your case you probably need to find the loop generating the forums and find a location inside the loop. A good place to start is to look at which php file is generating the page. (Of course if you can't find a hook location to do what you want there's nothing stopping you from changing the php file directly, but if you ever go to rebuild your site or upgrade you'll probably wish you hadn't gone that way).

Hope this helps.


All times are GMT. The time now is 04:39 PM.

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.01023 seconds
  • Memory Usage 1,710KB
  • 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
  • (1)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (2)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete