it is loaded in a php page class that uses file_get_content($theme). Is this a problem?
Considering that file_get_contents() does nothing but get the raw contents of a file, yes, that is a problem if you expect PHP to actually examine the contents of the file and execute any PHP code within it (such as what would be done if you were include()/require()'ing the file instead).
Considering that file_get_contents() does nothing but get the raw contents of a file, yes, that is a problem if you expect PHP to actually examine the contents of the file and execute any PHP code within it (such as what would be done if you were include()/require()'ing the file instead).
I see, so the problem will be fixed if I write include($theme) rather than file_get_content($theme)? Is it really that, simple?
Without seeing what you're doing with the contents of the file one can only guess; if (conceptually) replacing the call to file_get_contents() with a copy-paste of the contents of the file being got results in the Right Thing, then yes. If you're doing anything other than simply outputting it (in which case readfile() would have been a more straightforward choice), then probably not.
Alright thanks. I was wondering how this might work out since there are lots of placeholders in my html template. These placeholders are in the format of :TITLE:, :CONTENT, :SIDEBAR:, which provides a good reason to use get_file_content($template). PHP will replace these placeholders with php variables, this is how one single html file works for pretty much all php pages. I am not quite sure if the same effect can be achieved if I use include($template), since the entire template system may have to be redesigned otherwise.
And I'd like to ask if there is a way to separate html header from body. The problem can be easily resolved if the <head> tags can be placed in a different html file from <body>. I tried to search on google, but found nothing on how to accomplish this. I am not sure if this is even doable?
Of course it's "doable." Just do it.
You'd need to process both templates (head and body), of course, and make sure they're output in the correct order.
I see, that would be great. This way I have the header content 'included', while the body is loaded using get_file_content so the html can be partially converted to string with place holders replaced by php vars.
So is this the correct format?
header file
PHP Code:
<html> <head> // header content here </head>
Body File:
PHP Code:
<html> <body> // body content here </body> </html>
Thanks for all of your help, everyone. It works now, although it took me longer since I found out that the admin control panel's navlinks were messed up too. I fixed them in 2 hours.
Perhaps it is time for me to use smarty or a professional template system, this one aint really doing good.
Sorry to have to double post in the topic. I find the url rewriting is not working for get forms, the query string is still messed up. One possible solution is to get rid of get forms, but are there's one problem. Sometimes I do not know what url I will be getting since the url is variable, not fixed. This happens when the form contains drop down select/option elements, and the url depends on these values. What am I supposed to do in this case? I heard its possible to use javascript to get this to work, but I do not know how to do it. Is there another way?
Perhaps it is time for me to use smarty or a professional template system, this one aint really doing good.
IMO, Smarty and other template systems for PHP are largely counter-productive, especially for programmers (as opposed to "designers"). You have to learn a second set of rules, syntax, and workarounds for something you could be doing directly in PHP, without the overhead.
PHP is perfectly suited for templating all on its own. That's basically the task it was created for. template.php
Sorry to have to double post in the topic. I find the url rewriting is not working for get forms, the query string is still messed up. One possible solution is to get rid of get forms, but are there's one problem. Sometimes I do not know what url I will be getting since the url is variable, not fixed. This happens when the form contains drop down select/option elements, and the url depends on these values. What am I supposed to do in this case? I heard its possible to use javascript to get this to work, but I do not know how to do it. Is there another way?
Are you still talking about the URLs to your scripts/stylesheets (same as earlier in this thread)? I don't understand how the query string would be interfering with what we've discussed so far (or why there would be a query string in those URLs in the first place). Or are you talking about something else (you mentioned URL rewriting and form submissions)? Can you clarify/ give an example?
IMO, Smarty and other template systems for PHP are largely counter-productive, especially for programmers (as opposed to "designers"). You have to learn a second set of rules, syntax, and workarounds for something you could be doing directly in PHP, without the overhead.
PHP is perfectly suited for templating all on its own. That's basically the task it was created for. template.php
Are you still talking about the URLs to your scripts/stylesheets (same as earlier in this thread)? I don't understand how the query string would be interfering with what we've discussed so far (or why there would be a query string in those URLs in the first place). Or are you talking about something else (you mentioned URL rewriting and form submissions)? Can you clarify/ give an example?
Well the idea is that if I use a get form, the form parameters are automatically passed to the url and mess up the neat format I have been trying to establish. This is an example, although mine is somewhat different: http://forums.phpfreaks.com/topic/61...on-a-get-form/
So I know javascript can be used to solve the problem, but for my application the parameter keys vary from file to file so its tedious to use one javascript function to modify query strings. I was wondering if theres a better way to format the url when it involves a get form.
Of course a GET form "messes up" a "well-formed" URL (although 'well-formed' is a nebulous term).
Do you also complain that clear weather turns the sky blue?
How about submitting forms via POST and having a central "controller" script that decides where to send the browser, and with what variables attached. It might be written in such a way as to preserve your URI rewriting scheme ... whatever it is.
/!!\ mysql_ is deprecated --- don't use it! Tell your hosting company you will switch if they don't upgrade!/!!!\ ereg() is deprecated --- don't use it!
dalecosp "God doesn't play dice." --- Einstein "Perl is hardly a paragon of beautiful syntax." --- Weedpacket
Bookmarks