Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
#1 2008-10-28 15:14:55
- Nonsense
- Member
- Registered: 2005-11-25
- Posts: 53
Php include
I tried searching the forum for solution on this but couldn’t find any obvious answers (and yes, I have activated php-support in pages) so here it goes:
I’m trying to include a text from a php or text-file:
<txp:php>include 'http://www.domain.name/folder/title.php'; </txp:php>
The file “title.php” conatins the following:
Title
That didn’t work though.
I just want a quick and easy way to include a text from either a php or text-file on my server.
Last edited by Nonsense (2008-10-28 15:17:24)
Offline
Re: Php include
Use the proper file path, not the URL.
E.g.
<txp:php>include ('/webroot/folder/title.php'); </txp:php>
Offline
#3 2008-10-29 11:15:51
- Nonsense
- Member
- Registered: 2005-11-25
- Posts: 53
Re: Php include
That did the trick!
I used the tab described by the team at Textpattern to get the path:
<txp:php>var_dump(getcwd(), get_include_path());</txp:php>
http://textpattern.com/faq/34/how-do-i-use-php-code
The only this was that when I used that snippet I got quite a lot of alternatives to choose from.
So I broke the script as:
<txp:php>get_include_path());</txp:php>
Which gave me an error, but also a reference to the php path.
Offline
Offline
#5 2008-10-29 14:56:33
- Nonsense
- Member
- Registered: 2005-11-25
- Posts: 53
Re: Php include
Ah.
Quite right.
Offline
#6 2008-10-29 16:21:42
- masa
- Member
- From: Asturias, Spain
- Registered: 2005-11-25
- Posts: 1,091
Re: Php include
Isn’t that path information simply available from Txp’s Diagnostics tab?
Offline
Re: Php include
masa wrote:
Isn’t that path information simply available from Txp’s Diagnostics tab?
Yep, is. And in config, database and so on. And it isn’t even required always (dots, slashes – we love them). We even got defined txpath
etc.
And to add, if it’s only text file with out any PHP code, we shouldn’t/have to even use include. readfile, file_get_contents and other file functions are for that purpose.
Last edited by Gocom (2008-10-29 16:43:21)
Offline
#8 2008-10-29 18:41:20
- Nonsense
- Member
- Registered: 2005-11-25
- Posts: 53
Re: Php include
Oh.
I feel stupid now.
Offline
#9 2008-10-29 18:51:46
- masa
- Member
- From: Asturias, Spain
- Registered: 2005-11-25
- Posts: 1,091
Re: Php include
Nonsense wrote:
I feel stupid now.
Nah, no need – welcome to the club! :-)
Offline
Pages: 1