4images Forum & Community
4images Modifications / Modifikationen => Templates & Styles (Releases & Support) => Topic started by: Chris 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:
<?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 ?>
$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.
-
Hay Chris
Nice thread
I have a question
Is this work with query also ?
-
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. :roll:
-
Is this work with query also ?
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?
-
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!
-
No one? :cry:
-
Thanks man!
I'll try it
:wink:
-
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?
-
How would this work if you had, say 4 or more, php files to include and not just one?
-
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.
-
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.
-
if i don't use {} what is the problem. i have a site template that i prepare it for sale its not too professional but it works well.