View Full Version : How can I add PHP Code to the templates?
Hey,
I am starting to modify my template. I put some PHP code in the image_template.html. It is included via the index.php - though <?php ?> Tags are completely ignored.
Someone got an idea how I can put PHP Code in my Templates?
Thanks
/phoe
TheMarco
06-01-2008, 09:29 PM
You can't. What you can do however is create pixelpost tags like <MYCOOLDYNAMICSTUFF> and then create an add-on which dynamically replaces that with something produced by your PHP add-on.
In the Dark Matter template I added tons of extra functionality in that fashion. There's quite a few <DM_SOMETHING> tags which all get their stuff done in the dm_support.php add-on that comes with the theme. Take a look at it and you'll get the hang of it.
uhh... that sounds shitty, but if it's the only way to do it - I tink I got to do it ;)
TheMarco
06-01-2008, 09:36 PM
While there's a lot of things in Pixelpost that I would have done differently if I would be the programmer, I disagree that this particular aspect is 'shitty'. It's important to keep business logic code separated from a template. While I know that PHP allows you to mix HTML and code freely, I think THAT is actually 'shitty'. I know because I have to deal with that kind of stuff a lot in the epic mess called 'WordPress'.
sure. it's always the perspective you have on things.
from my perspective, I just want to add some basic things like a mysql based link list in my about page, a dynamic header cause I dont want to edit the header on every freakin template again when I want to change something....
so some PHP support would have been... standard?
I love the software - but it feels like the coders only had THEIR perspective in their head when writing this - and I have to admit - lovely software!
well maybe the forces me to write an addon I publish for the comunity;)
TheMarco
06-01-2008, 09:50 PM
Well as said, what you want is perfectly possible and easy to do. And the add-on mechanism is THE way to keep all your code away from the template markup. It does exactly what you describe as your needs.
witty
06-02-2008, 01:33 AM
Hi,
well maybe the forces me to write an addon I publish for the comunity.
See, you've gone from "shitty" to realizing the magic and fun that is Pixelpost! I look forward to checking out your add-on when it's finished. Good luck!
-Witty
vBulletin® v3.7.3, Copyright ©2000-2013, Jelsoft Enterprises Ltd.