4images Forum & Community
Welcome, Guest. Please login or register.
Did you miss your activation email?
February 24, 2018, 07:04:28 AM

Login with username, password and session length
Search:     Advanced search
Follow 4images on twitter: Click here to follow!
Togle to toolbar
Translate this page with =>
Translate this page >
* Home Help Search Login Register
 
+  4images Forum & Community
|-+  4images Modifications / Modifikationen
| |-+  Templates & Styles (Releases & Support) (Moderator: Rembrandt)
| | |-+  To Template Developers: avoid using PHP code in templates
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] Print
This topic has not yet been rated!
Author Topic: To Template Developers: avoid using PHP code in templates  (Read 42091 times)
Chris
4images Moderator
4images Guru
*****
Offline Offline

Posts: 4487

Thank You
-Given: 0
-Receive: 31

Did u ever stop to think and then forget to start?


View Profile
« on: March 17, 2005, 04:00:46 AM »

If u are making templates avalable for the public, try to avoid using PHP code inside the template, because many people experiensing lots of problems just cause of that!
Yes, I know, that by including "menu.php" file u can do changes in that file and without need editing each template. Agreed, that's the easiest way to do, but the side effect of that can cause number 2 problem discusing on this forum: eval() error.

so, what u can do about that? - simply replace all your <?php ... ?> code with {...} tag.
let me give u an idea how to do it.
lets say in your template u have this PHP code:
1
2
3
<?php
include('menu.php');
?>
this inserts in the template what ever is in /menu.php file.
most of the time the file contains plain HTML code.

now, you replace the PHP code (as above) with this tag: {4images_menu} (Explanation let's make it "standard" tag, that everyone would use same tag everywhere Wink). Then, u create a new template: /templates/<yourtemplate>/4images_menu.html with the code from menu.php
In the installation.txt guide u state, that if this is a first time installation of new template, then they should add two lines, in /includes/page_header.php file, at the end, just before closing ?>
1
2
$menu = (file_exists(TEMPLATE_PATH."/4images_menu.html")) ? $site_template->parse_template("4images_menu") : "";
$site_template->register_vars("4images_menu", $menu);

that's all, now all {4images_menu} tags will be replaces with whatever u put into 4mages_menu.html template.

Hope this will go as some sort of guide for templete developers, cause as I mentioned above, eval() error is number 2 problem after SAFE MODE, but work around it is much easier.

Follow members gave a thank to your post:
safavinet

For this post, 1 member gave a thank you!
« Last Edit: September 27, 2008, 11:32:04 AM by KurtW » Logged

abdoh2010
Jr. Member
**
Offline Offline

Posts: 96

Thank You
-Given: 0
-Receive: 1


View Profile WWW
« Reply #1 on: April 04, 2005, 03:55:14 PM »

Hay Chris
Nice thread

I have a question

Is this work with query also ?

Follow members gave a thank to your post:
safavinet

For this post, 1 member gave a thank you!
Logged
Chris
4images Moderator
4images Guru
*****
Offline Offline

Posts: 4487

Thank You
-Given: 0
-Receive: 31

Did u ever stop to think and then forget to start?


View Profile
« Reply #2 on: April 11, 2005, 03:59:43 AM »

Sorry but I don't know what you mean.  V@no is the one who posted this original.  I just reposted it out of the search engine cache.  Rolling Eyes

Follow members gave a thank to your post:
safavinet

For this post, 1 member gave a thank you!
Logged

V@no
If you don't tell me what to do, I won't tell you where you should go :)
Administrator
4images Guru
*****
Offline Offline

Posts: 17849

Thank You
-Given: 47
-Receive: 565

mmm PHP...


View Profile WWW
« Reply #3 on: April 11, 2005, 05:21:36 AM »

I've seen several posts of yours with questions about "query"... I think u missunderstanding the meaning of word "query" or dont know that there are more then one meaning of that word exists...
so, what "query" are u talking about?

Follow members gave a thank to your post:
safavinet

For this post, 1 member gave a thank you!
Logged

Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)
ClickyMouse
Jr. Member
**
Offline Offline

Posts: 54

Thank You
-Given: 0
-Receive: 0


View Profile
« Reply #4 on: January 31, 2008, 09:16:46 PM »

1
Parse error: syntax error, unexpected T_LNUMBER, expecting T_VARIABLE or '$' in /www/110mb.com/g/r/u/p/o/s/c/o/gruposcout508/htdocs/fotos/includes/template.php(101) : eval()'d code on line 2

I've used the exact example that you gave.

And I've created the 4images_menu.html file on my template folder...

What's wrong?

Thanks!
Logged
ClickyMouse
Jr. Member
**
Offline Offline

Posts: 54

Thank You
-Given: 0
-Receive: 0


View Profile
« Reply #5 on: February 01, 2008, 05:30:17 PM »

No one?  Crying or Very sad
Logged
ivan
4images Moderator
4images Guru
*****
Offline Offline

Posts: 2279

Thank You
-Given: 4
-Receive: 30


View Profile WWW
« Reply #6 on: February 01, 2008, 05:35:44 PM »

use this...
is better Wink

http://www.4homepages.de/forum/index.php?topic=18926.0
Logged

greetings / grüsse
ivan

Facebook Fan Page | Follow Twitter

Blog: Reisen Blog
Bilder Gallery: Bilder Gallery
ClickyMouse
Jr. Member
**
Offline Offline

Posts: 54

Thank You
-Given: 0
-Receive: 0


View Profile
« Reply #7 on: February 01, 2008, 05:37:29 PM »

Thanks man!
I'll try it

 Wink
Logged
capeinfo
Pre-Newbie

Offline Offline

Posts: 1

Thank You
-Given: 0
-Receive: 0


View Profile
« Reply #8 on: March 12, 2008, 11:38:12 AM »

Thank you for a really great application.  Well done!

Do you have any suggestions if one just has to use PHP templates - our menu includes a search facility that is dynamically-driven?
Logged
Twilight
Pre-Newbie

Offline Offline

Posts: 2

Thank You
-Given: 0
-Receive: 0


View Profile
« Reply #9 on: August 10, 2008, 05:20:33 AM »

How would this work if you had, say 4 or more, php files to include and not just one?
Logged
V@no
If you don't tell me what to do, I won't tell you where you should go :)
Administrator
4images Guru
*****
Offline Offline

Posts: 17849

Thank You
-Given: 47
-Receive: 565

mmm PHP...


View Profile WWW
« Reply #10 on: August 10, 2008, 07:32:57 AM »

This topic was created when 4images v1.7 was the latest. Since then 4images handles php code inside templates much better. You can and I'd even say preferable use php code instead of registering new tags. (template tags require more server resources then plain php code)
The only problem with php code in templates, is that its hard to trace errors.
Logged

Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)
Twilight
Pre-Newbie

Offline Offline

Posts: 2

Thank You
-Given: 0
-Receive: 0


View Profile
« Reply #11 on: August 11, 2008, 08:35:29 PM »

Thank you so much for the quick response! I am working on a template design that i wanted to offer for free from my site, so i was just trying to find the most efficient way to add in the perks i was wanting to add without causing problems for the users.
When i seen this thread, i was concerned that by adding them, i could be causing possible problems. Its good to know that it is no longer an issue.
Logged
Pages: [1] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.083 seconds with 23 queries.