PDA

View Full Version : Limited PHP scripts functionality for templates v1.0


JohnWoo
02 Jan 2003, 20:01
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
02 Jan 2003, 20:16
hey, looks nice :)

Dean C
02 Jan 2003, 20:35
Indeed this looks very nice.

But what if a template is called by more than one file?

- miSt

JohnWoo
02 Jan 2003, 21:05
then why not to use some condition checking #PHP_SELF in template code ?

DrkFusion
02 Jan 2003, 21:37
he got u there mist ;)
Looking nice JohnWooo
I will check it out when I get home

Velocd
03 Jan 2003, 00:43
Interesting, but for organizational methods I like to keep PHP separate from the templates :p

DrkFusion
03 Jan 2003, 04:04
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 :)

nuno
03 Jan 2003, 04:45
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
03 Jan 2003, 07:48
It is "limited functionality". Remember? :) echo will not work - sorry :) Try to replace echo with return.

VeoMorphine
03 Jan 2003, 16:54
nice. we should release template mods with this(they might like this on www.vbulletintemplates.com to.

Xenon
03 Jan 2003, 21:21
@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
04 Jan 2003, 21:45
Hmm... The 1.1 zip seems to be empty...

JohnWoo
04 Jan 2003, 22:19
Updated :)
It downloads fine for me (and before it was fine too)

Brad
05 Jan 2003, 01:18
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
05 Jan 2003, 08:00
But phpinclude will be executed on any page of forum, and think that it is not good :)

Brad
05 Jan 2003, 11:20
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
05 Jan 2003, 11:21
Nice Idea;)

@Anime-loo - Wouldn't "$DB_site->query" be better?

Satan

JohnWoo
05 Jan 2003, 11:42
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...

Brad
05 Jan 2003, 12:09
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
05 Jan 2003, 12:13
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.