Welcome to Geeklog, Anonymous Wednesday, December 11 2024 @ 05:48 am EST
Geeklog Forums
Why PHP only in some templates?
Status: offline
LWC
Forum User
Full Member
Registered: 02/19/04
Posts: 818
What's so special about files like (featured)storytext.thtml and footer.thtml that stops me from directly using PHP in them (like I can in, say, header.php)?
If I try, it's just as if I tried to use PHP code in a regular HTML page.
Yes, of course I can do it via system/lib-story.php, lib-common.thtml, etc. but those files are customized anyway so it's annoying to customize in 2 different places each time instead of one.
If I try, it's just as if I tried to use PHP code in a regular HTML page.
Yes, of course I can do it via system/lib-story.php, lib-common.thtml, etc. but those files are customized anyway so it's annoying to customize in 2 different places each time instead of one.
14
13
Quote
blah
Anonymous
The header.thtml is the only file that you should be able to use php in. The reason for this is they are template files, if it were all php it would cause a ton of overhead and using templates would be meaningless in the first place.
No idea why you can't use php at the end of your header.thtml file other then to suspect you have a typo in your code.
No idea why you can't use php at the end of your header.thtml file other then to suspect you have a typo in your code.
15
13
Quote
Status: offline
LWC
Forum User
Full Member
Registered: 02/19/04
Posts: 818
Look, the word php and the code are just shown as HTML. It only happens if the code is around the comment "START OF CONTENT AREA".
And I still like to know how come it just (generally) works in header.thtml. What's so special about it?
And I still like to know how come it just (generally) works in header.thtml. What's so special about it?
13
15
Quote
Status: offline
ajohnson
Forum User
Junior
Registered: 06/16/06
Posts: 26
The reason you are having trouble can be due to two things. One, you are putting the added markup in the wrong place, or two, you are writing invalid markup. There is nothing special about any .thtml file. They are just segments of a web page to be assembled by GL.
13
12
Quote
Status: offline
LWC
Forum User
Full Member
Registered: 02/19/04
Posts: 818
Look, if you don't know the answer don't reply, but stop blaming me for not knowing PHP.
It's real simple. PHP works in most of header.thtml, just not if I use it towards the end of the file. In the other templates I've mentioned it doesn't work anywhere.
It's real simple. PHP works in most of header.thtml, just not if I use it towards the end of the file. In the other templates I've mentioned it doesn't work anywhere.
11
11
Quote
Status: offline
ajohnson
Forum User
Junior
Registered: 06/16/06
Posts: 26
You misunderstand. You need to write valid HTML for a site to render properly. The .thtml pages are segments of a whole page. Just putting a code snippet somewhere , anywhere does not work. You need to place things in such a way that when the pages are joined, the markup is not broken. Yopu are somehow breaking the page. I also know how to write valid html and I make mistakes too. We all do.
12
13
Quote
Status: offline
Dirk
Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
Quote by LWC: And I still like to know how come it just (generally) works in header.thtml. What's so special about it?
Because it's run through eval() and because it's documented that it only works in header.thtml.
bye, Dirk
11
14
Quote
Status: offline
LWC
Forum User
Full Member
Registered: 02/19/04
Posts: 818
Well, at least now I know it's documented. What do the other templates use if not eval()? And how come it doesn't work towards the end of header.thtml? Can you at least tell me the percise point when it stops working?
Thanks!
Thanks!
17
10
Quote
blah
Anonymous
Quote by LWC: Look, if you don't know the answer don't reply, but stop blaming me for not knowing PHP.
Sorry for trying to help it wont happen again.
11
13
Quote
blah
Anonymous
btw this bit of code works everywhere in my header.thtml file, including within the comment you seem to be having issues with.
<?php
echo 'blah';
?>
I was never trying to suggest you don't know how to code php just that perhaps you had a typo somewhere or something. Not trying to help here but are you sure you incased you code in
tags?
Text Formatted Code
<?php
echo 'blah';
?>
I was never trying to suggest you don't know how to code php just that perhaps you had a typo somewhere or something. Not trying to help here but are you sure you incased you code in
Text Formatted Code
<?php and ?>
11
14
Quote
All times are EST. The time is now 05:48 am.
- Normal Topic
- Sticky Topic
- Locked Topic
- New Post
- Sticky Topic W/ New Post
- Locked Topic W/ New Post
- View Anonymous Posts
- Able to post
- Filtered HTML Allowed
- Censored Content