vb.org Archive

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

smokey 03-20-2003 05:50 PM

Php parsing in templates
 
Hello, i created my own little stars addon for my forums, a quite simple addon for when i do upgrades, i wont have to re-edit any of my vb files. The problem is not with the php or mysql, it is calling the php in the template. I added the variable '$stars' in the postbit template and it isent comming up. It worked on the earlier versions of vbulletin 2 but now that i try it now, it will not show up on my users posts. Basicly the problem im having is calling a php file in a template. I added the following line in my showthreads.php:

PHP Code:

include('stars.php'); 

I dont understand exacly how these templates are setup. Any suggestions? My current vb version is 2.2.9 and you may find it at http://www.c2kforums.net/vb/index.php

Thank you for your time.

Xenon 03-20-2003 05:57 PM

just the template phpinclude will be executed and there phpcode can be used, in no other templates!

smokey 03-21-2003 12:18 AM

I still get nothin, i want to put the stars right under the usertitle in the postbit template, i have the phpcoding in showthreads.php and i added $stars in postbit. Is there anyway i can accually get them to show up? i even tried adding replacements and doing the coding in the phpinclude template

filburt1 03-21-2003 12:54 AM

You virtually never can edit bit templates via phpinclude. You almost always have to hack.

smokey 03-21-2003 01:07 AM

this i know, i added my script in showthread.php and i cant figure out how to make the variable $stars come up. I never really had a problem with phpscripting but i cant quite figure this out

filburt1 03-21-2003 01:08 AM

Make sure $stars is in a global scope (the scope in which all templates are eval'ed AFAIK).

smokey 03-21-2003 01:12 AM

a global scope? like eval()? and should this be done in showthread.php and do you have an example so i can understand exacly what you mean?

smokey 03-22-2003 02:20 AM

heh, nevermind, guess i will have to figure it out my self...

smokey 03-25-2003 12:24 AM

last time im asking a simple question here, thanks for nothing

mr e 03-25-2003 12:37 AM

by global scope he means right above where the file does it's final dooutput('postbit') for example

dejoslav 03-25-2003 01:20 PM

I also need to do the same thing... add a php code in a specific place in showthread template but I don't know how.

What do you use phpinclude template for?

filburt1 03-25-2003 02:26 PM

Quote:

Yesterday at 09:24 PM smokey said this in Post #9
last time im asking a simple question here, thanks for nothing

You'll never get any help here with that attitude. These people are using their own personal time to help you with your problem, the least you could do is show some gratitude.

dejoslav 03-25-2003 02:39 PM

I guess it could work this way (I haven't tried it actually), but it looks little messy. All you need to do is to split a template on two templates at the point you want to insert your php code... ie. from first part of showthread template make showthread1 and from the rest showthread2.

Then edit showthread.php and replace the following line

PHP Code:

eval("dooutput(\"".gettemplate("showthread")."\");"); 

with:

PHP Code:

eval("dooutput(\"".gettemplate("showthread1")."\");");
// .... your PHP code goes here...
eval("dooutput(\"".gettemplate("showthread2")."\");"); 

I guess it should work, but I'd rather use some cleaner method....

dejoslav 03-28-2003 11:25 AM

Or there is another way I just tried... Right in front of the following line in showthread.php

eval("dooutput(\"".gettemplate("showthread")."\"); ");

make a line of of text you wish to appear somewhere on the showthread page. Just put everything you want in one variable, i.e $myvariable. All you need to do then is to put $myvariable somewhere in the showthread template...

Brad 03-28-2003 12:05 PM

Quote:

03-20-03 at 09:18 PM smokey said this in Post #3
I still get nothin, i want to put the stars right under the usertitle in the postbit template, i have the phpcoding in showthreads.php and i added $stars in postbit. Is there anyway i can accually get them to show up? i even tried adding replacements and doing the coding in the phpinclude template

Edit /admin/functions.php insted. Search for this:

PHP Code:

// ###################### Start buildpostbit ####################### 



All times are GMT. The time now is 04:43 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.01058 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
  • (4)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (15)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