Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#73 2011-09-29 12:48:58

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: rah_external_output

jakob wrote:

A possible feature idea (coming from here): how about making it possible to import and export rah_external_output snippets for easy portability in much the same manner as you can with smd_macro?

The whole database table is portable, or how-to-put it… self-containable — it has no tie-ins with other tables, indexes or anything. I would say easiest way to export snippets is just to dump the table. Importing the dump would then create the snippets.

An alternative idea – or an additional idea – would be to expand cnk_versioning to work with smd_macro and rah_external_output snippets. Then again, perhaps I’m just getting too lazy…

Unfortunately my update schedule as-of-now doesn’t really fit another public cross-system project, especially when 4.x is closing it’s life-cycle (which likely means long update cycle with existing plugins). Need to be able to provide support for current projects.

Agreed, someone most certainly should adopt cnk_versioning, overall the plugin could take some fresh mints. In my melon shaped head the ideal cnk_versioning would allow user-configurable database mapping. One would just tell what file in what directory goes into what field in a what table, and so-on. Maybe even additional XML support for more complex scenarios, possibly the mappings itself were handled by XML files.

Last edited by Gocom (2011-09-29 13:06:16)

Offline

#74 2012-01-04 19:20:05

sidekarsten
Member
From: Netherlands
Registered: 2011-08-11
Posts: 34
Website

Re: rah_external_output

Question,

I got this plugin to work to get content from one TXP site to show up in another TXP site… which is very cool! However, is it also possible to use this plugin to imports “forms” without the content? I’d like to make several different but related websites, it would be nice if I could use this plugin to host a form database as it were to be pulled in and used for my other sites, would such a thing be possible somehow?

Offline

#75 2012-01-04 20:37:37

milosevic
Member
From: Madrid, Spain
Registered: 2005-09-19
Posts: 390

Re: rah_external_output

mmm, I’m not sure, but perhaps you can do a Textpattern multisite installation (one core for presentation, several databases or tables for the content per site). I have never do it, but if you google it you will find information.


<txp:rocks/>

Offline

#76 2012-01-04 21:36:38

sidekarsten
Member
From: Netherlands
Registered: 2011-08-11
Posts: 34
Website

Re: rah_external_output

That was indeed what I was trying to do…. however, if I copy paste a form and add it as a snippet in rah_external_output it uses the form to pull in actual content from the database the snippet is part of… rather I would like to pull in the form code, as code, so that the content is subsequently loaded from the database that pulls in the form through rah_external_output… In that scenario I can use the rah_external_output snippets from the main database as the templates or building blocks for my pages and forms in my related websites…

Offline

#77 2012-01-04 22:12:10

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: rah_external_output

I doubt rah_external_output will help you to achieve easily what are you trying to (although Gocom may have some clever trick under his sleeves). It will require something like rah_external_output sending the plain text (not parsed) for the forms & pages, which then your other related website will need to pick up and parse in real time or maybe, dump it back to the database, and then, parse/render it with the contents. Sounds like an overthought mechanism…

I’ve done something similar (share pages & forms across a few related websites, each one with its own content) a few times in the past.
A multi-site installation may be helpful although it’s not mandatory for this kind of setup.
The main question is: are all these related website going to be hosted on the same server? Not mandatory neither, but sharing pages & forms across websites hosted in different servers may be a bit more trickier (it may probably require mounting a folder from the main website server into every related website hosting).

In any case, the key to get this setup working is using cnk_versioning. a plugin that lets you store pages & forms in the filesystem (making edition/versioning easier), and that there are “dumped back” to database.

So, you could create two folderes (forms/ and pages/) to store all your forms & pages, and then, you could configure cnk_versioning on each website (the main one and the related ones) to look for forms & pages on those two folders. This may be even easier to setup with a few symlinks properly placed.
Taking this one step further, you could store forms & pages on some common folder, but then, on each particular website, create the two necessary folders (again, forms/ and pages/), and from inside those two folders, create symlink only to some (not all) pages & forms that you would like to share across all the websites.

Time to tinker!


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#78 2012-01-04 23:50:24

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: rah_external_output

sidekarsten, I’ve moved our discussion to cnk_versioning thread, to avoid hijacking further this plugin’s thread.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#79 2012-02-01 12:51:58

MarcoK
Plugin Author
From: Como
Registered: 2006-10-17
Posts: 248
Website

Re: rah_external_output

Hi.

I have try to get as output an image:

<txp:php>
header("Content-Type: image/jpg");
$image = imagecreate(200,295);
imagejpeg($image);
imagedestroy($image);
</txp:php>

but I obtain always an error: the image contain errors.

Why? If i past this code into a php file it work fine!

Offline

#80 2012-02-01 14:04:29

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: rah_external_output

MarcoK wrote:

I have try to get as output an image:

As a general warning, please avoid creating images on fly. You will at least want a caching mechanism and preferably you would link to actual flat files instead of a PHP page. Initializing a CMS for generating image isn’t the best way to ensure that your website is up and running.

but I obtain always an error: the image contain errors.

The code works correctly for me. I get the intended black box of doom. Uses lot of memory, as could be expected and I certainly wouldn’t use it in real world, but it works. I suggest making sure that the image is created successfully (no feces is hitting the fan), and after that making sure that there is nothing else returning (echoing) anything. No code causing errors (plugins etc), no conflicts with any plugins (no plugins that hook on events, use echo etc, modify page contents on fly), no trailing whitespace coming from any PHP files (no newlines at the end of the file), and no on-fly page compressing is interfering.

header("Content-Type: image/jpg");

I would suggest adding image/jpg to the Content-type field on the editor and removing that line. The plugin sends a content-type header.

Offline

#81 2012-02-01 16:41:48

MarcoK
Plugin Author
From: Como
Registered: 2006-10-17
Posts: 248
Website

Re: rah_external_output

Thanks

Offline

#82 2012-02-10 09:56:50

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

Re: rah_external_output

Hi Jukka,

I am using this plugin extensively to link content between sites. Thanks! Can you please advice on the php code I need to output some static content should the server has an error (such as database unavailable, 500, etc)

At the moment I am using <?php include($DOCUMENT_ROOT . "http://www.site.tld/?rah_external_output=something"); ?> Ideally it should be something like

if content fetched: include;
else;
some static html here;

Any advice would be appreciated

Last edited by colak (2012-02-10 09:58:56)


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

Offline

#83 2012-02-10 10:36:24

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: rah_external_output

colak wrote:

Can you please advice on the php code I need to output some static content should the server has an error (such as database unavailable, 500, etc)

Yiannis, you asked same question two year ago ;-) My past self replied. Quoting my past self, with cURL you can get the HTTP status code returned by the server. E.g.

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://example.com/?rah_external_output=snippet');
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
$file = curl_exec($ch);
$http = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo $file !== false && $http == '200' ? $file : 'Error appeared. Sad face.';

Above is same deal as in the old reply. Requires cURL.

Last edited by Gocom (2012-02-10 10:52:21)

Offline

#84 2012-02-10 14:23:18

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

Re: rah_external_output

Hi Jukka, Now that you made your time travel I remember about the discussion. Unfortunately then, the code returned an error when used in a txp site. When I use it in an independent php page now, the txp content is not fetched and it shows the alternative html instead.

Last edited by colak (2012-02-10 14:23:43)


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

Offline

Board footer

Powered by FluxBB