View Full Version : Limited PHP scripts functionality for templates v1.0
JohnWoo
01-01-2003, 10:00 PM
Hello all !
Here is small funny hack (5 strings of new code only in one script :) That may help to bring more power to vb templates :)
Features:
- executing php scripts (with modified syntax) from templates. Changing\creating php variables from templates, conditional actions and database requests without editing scripts.
It is all :)
PS changes in 1.1
- normal php variables syntax (with $)
- added example of database request from template
- support for several PHP blocks in one template
Xenon
01-02-2003, 07:16 PM
hey, looks nice :)
Dean C
01-02-2003, 07:35 PM
Indeed this looks very nice.
But what if a template is called by more than one file?
- miSt
JohnWoo
01-02-2003, 08:05 PM
then why not to use some condition checking #PHP_SELF in template code ?
DrkFusion
01-02-2003, 08:37 PM
he got u there mist ;)
Looking nice JohnWooo
I will check it out when I get home
Velocd
01-02-2003, 11:43 PM
Interesting, but for organizational methods I like to keep PHP separate from the templates :p
DrkFusion
01-03-2003, 03:04 AM
Organizational?
Well I would use this in a case of when I am lazy to add 3 lines of code that do 1 thing one 1 page.
So it would be pretty useful in my caze :)
hmm seems not to be working correctly :(
I was trying to pull out the the filesize attachments
~%#data = 'index.php';#id = filesize(#data);echo "Filesize for #data: (#id)"%~
It gets printed at left top corner page and not right after attachment :confused:
JohnWoo
01-03-2003, 06:48 AM
It is "limited functionality". Remember? :) echo will not work - sorry :) Try to replace echo with return.
VeoMorphine
01-03-2003, 03:54 PM
nice. we should release template mods with this(they might like this on www.vbulletintemplates.com to.
Xenon
01-03-2003, 08:21 PM
@Velo: yeh, but sometimes this can be usefull to, if you just want to calculate some values (ppd directly in the template instead of the code)
The Prohacker
01-04-2003, 08:45 PM
Hmm... The 1.1 zip seems to be empty...
JohnWoo
01-04-2003, 09:19 PM
Updated :)
It downloads fine for me (and before it was fine too)
Originally posted by VeoMorphine
nice. we should release template mods with this(they might like this on www.vbulletintemplates.com to.
We have our own wrapper that works from the phpinclude template. Its a bit more work to code with it but it keeps us from hacking files. We have many of the hacks here working with only the phpinclude.
JohnWoo
01-05-2003, 07:00 AM
But phpinclude will be executed on any page of forum, and think that it is not good :)
Acully no. for example this would only be ran on index.php, The query it exucutes will only be done on that page, its ignored on all others.
if (strpos($_SERVER['PHP_SELF'], 'index.php') != false)
{
$query='code here'
}
Chris M
01-05-2003, 10:21 AM
Nice Idea;)
@Anime-loo - Wouldn't "$DB_site->query" be better?
Satan
JohnWoo
01-05-2003, 10:42 AM
Yes. It is another way. But what if you need to execute some code inside some loop ? :) Think that for example calculating something different for each post on showthread.php must be impossible using phpinclude only...
Originally posted by hellsatan
Nice Idea;)
@Anime-loo - Wouldn't "$DB_site->query" be better?
Satan
yes, i was only showing a example ;) this would be the correct useage if you where ganna show the result of the query on index.php
$query=$DB_site->query_frist
Xenon
01-05-2003, 11:13 AM
also it's not good to expand the phpinclude template such a lot.
rembember it's loaded on everypage, also if everything is in an if-clause it has to be loaded and so on.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.