View Full Version : Php parsing in templates
smokey
03-20-2003, 05:50 PM
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:
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
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
Yesterday at 09:24 PM smokey said this in Post #9 (https://vborg.vbsupport.ru/showthread.php?postid=372737#post372737)
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
eval("dooutput(\"".gettemplate("showthread")."\");");
with:
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...
03-20-03 at 09:18 PM smokey said this in Post #3 (https://vborg.vbsupport.ru/showthread.php?postid=370310#post370310)
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:
// ###################### Start buildpostbit #######################
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.