Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2007-10-22 13:15:12

zeeforel
Member
From: Nieuwerkerk a/d IJssel, NL
Registered: 2004-10-16
Posts: 92
Website

Running external PHP file based on current article id and category

Hi to you all,

I am thinking about TxP calling an external php application with it’s own small database. But how do I do that?

Some questions:
+ Can I nest the php in a “presentation file”?
+ How do I “bring” the current TxP article ID and category to the external php app?
+ How do I give information back from the external app so that TxP takes it up and presents it in the page layout? Via “echo …..”?

I am a beginner in php by the way, but very eager to learn.

All help appreciated! Many thanks in advance.

Best regards,
Marcel

Offline

#2 2007-10-22 14:55:17

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,090
Website GitHub Mastodon Twitter

Re: Running external PHP file based on current article id and category

My methods are simple and sometimes simplistic but…

How do I “bring” the current TxP article ID and category…

You could use txp’s rss feeds and a parser to provide links to the articles in the txp db.

How do I give information back from the external app so that TxP takes it up and presents it in the page layout?

rss again?


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#3 2007-10-22 15:30:27

zeeforel
Member
From: Nieuwerkerk a/d IJssel, NL
Registered: 2004-10-16
Posts: 92
Website

Re: Running external PHP file based on current article id and category

Hi Colak,

Thanks for your reply. However I think it is a bit simplistic. Let me provide some more details:

In page template:

<txp:php> ……some external application is called using {current article id and categorie(s) as parameter} ….. </txp:php>

+ the external application retrieves some information from an external database based on article ID and categories
+ the extracted information from the database is then placed back in the template as part of the HTML and presented to the user in the browser

I have a feeling this is a bit hard with RSS since it could be refering to older articles as well, but I might be wrong.

Please have another look.

Thanks.

Best regards,
Marcel

Offline

#4 2007-10-22 15:51:07

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,090
Website GitHub Mastodon Twitter

Re: Running external PHP file based on current article id and category

I have a feeling this is a bit hard with RSS since it could be refering to older articles as well, but I might be wrong.

not if the rss limit is “1”. Yet again that would limit the txp site’s possibilities. Not sure, but I think that there are feed parsers out there which can be set to show as many feeds as the user chooses, especially if that number is below the available feeds of the site.

I’m using the rss parsers on most of my sites (below). Admittedly I am only interested in linked titles but I’m sure that bring in the excerpt shouldn’t be a big problem. I seem to remember a plugin here which can be used to parse the body in the feeds.


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#5 2007-10-22 16:08:04

zeeforel
Member
From: Nieuwerkerk a/d IJssel, NL
Registered: 2004-10-16
Posts: 92
Website

Re: Running external PHP file based on current article id and category

Hi Colak,

But isn’t there any possibility to get from TxP the article ID in some kind of variable to re-use in external php, while it is bringing the template to the browser?

It looks as some kind of API on TxP though….

Marcel

Offline

#6 2007-10-22 16:17:11

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,090
Website GitHub Mastodon Twitter

Re: Running external PHP file based on current article id and category

But isn’t there any possibility to get from TxP the article ID in some kind of variable to re-use in external php

Unfortunately not


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#7 2007-10-22 16:22:43

zeeforel
Member
From: Nieuwerkerk a/d IJssel, NL
Registered: 2004-10-16
Posts: 92
Website

Re: Running external PHP file based on current article id and category

That links to precisely the other way around if you ask me… So I still have hope…..

I want to wrap my external application in TxP.

Last edited by zeeforel (2007-10-22 16:25:14)

Offline

#8 2007-10-22 18:35:25

wet
Developer Emeritus
From: Schoerfling, Austria
Registered: 2005-06-06
Posts: 3,330
Website Mastodon

Re: Running external PHP file based on current article id and category

I’d suggest to code at least a small Textpattern plugin which collects all necessary information, calls your external app and echoes its output back to the Textpattern page parser. As you are new to PHP, this would require external help, I suppose.

Offline

#9 2007-10-22 18:46:16

zeeforel
Member
From: Nieuwerkerk a/d IJssel, NL
Registered: 2004-10-16
Posts: 92
Website

Re: Running external PHP file based on current article id and category

Hi Wet,

Thanks for pointing that out.

I did manage to find this, which at least points to how to get the article id etc. I will try to experiment with this a bit.

Best regards,

Marcel

Offline

#10 2007-10-22 18:52:08

wet
Developer Emeritus
From: Schoerfling, Austria
Registered: 2005-06-06
Posts: 3,330
Website Mastodon

Re: Running external PHP file based on current article id and category

Offline

Board footer

Powered by FluxBB