Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2006-06-04 11:19:18

mikefireball
New Member
Registered: 2006-06-04
Posts: 2
Website

PHP include url based on a txp tag?

I’m not having much luck finding what I want to do on here, so if someone could point me in the right direction, I have what may very well be a simple problem…

Here’s a permalink of what I’m trying to set up:
http://progressiveboink.com/txp/dugout/2/farnsworth-vs-a-metal-fan

I’m far from complete (read: ignore the menus on the right for now).
What I’m focusing on now is in the area on the lower-left that looks like an AIM chat box.
I want to include an external file that would vary with each post, so that the final result would look like this:
http://progressiveboink.com/dugout/indexNEW.html

I’ve come up with three possible solutions that I can’t quite figure out…

1. Include a url based on the article_id value. In the example above, I’d want it to include
$_SERVER[‘DOCUMENT_ROOT’].”/dugout/chats/2.html

Right now it’s being handled by a form that looks like this:
<code>
<txp:php>
include($_SERVER[‘DOCUMENT_ROOT’].”/dugout/chats/article_id.html”);
</txp:php>
</code>
I haven’t figured out how to get the article_id tag into that url.

2. I’ve also considered the possibility of including text from the article’s exerpt in place of the article_id above. Same problem arises… how to call a txp tag in the middle of a php include.

3. If there’s a way to include it as a file that I’ve uploaded into Textpattern, I haven’t figured that out, either.

Little help, please?

Offline

#2 2006-06-04 14:33:46

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: PHP include url based on a txp tag?

<txp:php>
global $thisarticle; 

$chat_path = $_SERVER['DOCUMENT_ROOT'].'/dugout/chats/'.$thisarticle['thisid'].'.html';

if (file_exists($chat_path))
{
	include($chat_path);
}
</txp:php>

Make sure you’ve got this in an article form.

Offline

#3 2006-06-04 15:16:28

mikefireball
New Member
Registered: 2006-06-04
Posts: 2
Website

Re: PHP include url based on a txp tag?

Brilliant. Thanks for the quick reply!

Offline

Board footer

Powered by FluxBB