Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Re: rah_external_output
Want to use jquery .load function to pull content from a single textpattern install into several different static sites.
All sites are similar in that they only require a single BUTTON text and code to be edited.
I would like 1 txp install to power 6 different sites that have minor variations of info between them.
Because of cross-domain issue due to Same Origin Policy – i can’t do this easily
can I use this plugin to achieve what I need to accomplish?, and if so
what is the simplest method of doing so?
suggestions welcome! :)
Last edited by robbiia (2012-10-08 20:47:58)
Offline
Re: rah_external_output
—
Last edited by robbiia (2012-10-08 18:57:27)
Offline
Re: rah_external_output
Here is the link for the final site: http://www.chicagomeditation.com/new_site/index_ajax.html
Here is the link I am wanting to “pull” content from: http://www.introtomeditation.com/brochure/?rah_external_output=master.html
Help welcome.
:)
Last edited by robbiia (2012-10-08 18:57:51)
Offline
#100 2012-10-08 21:22:20
Re: rah_external_output
Have you added a html content-type to your external output ?
; Content-type: text/html
See plugin help
Offline
#101 2012-10-08 23:22:55
Re: rah_external_output
@sacripant
Thank you
I actually just found out a solution from this forum:
I made a get.php file with:
<?php
$curl = curl_init();
curl_setopt ($curl, CURLOPT_URL, 'example.com/?rah_external_output=name.html');
curl_setopt ($curl, CURLOPT_RETURNTRANSFER, 1);
echo curl_exec ($curl);
curl_close ($curl);
?>
and then .load with jquery like:
$("div").load('get.php');
Offline
#102 2013-03-07 14:28:29
- Algaris
- Member
- From: England
- Registered: 2006-01-27
- Posts: 548
Re: rah_external_output
I’m having some difficulties trying to include a snippet within a website. Here’s the URL I’m trying to include: http://example.com/calendar/?rah_external_output=db_events
This is the code I’m using to include the snippet:
<txp:php>
include($DOCUMENT_ROOT .
'http://example.com/calendar/?rah_external_output=db_events'
);
</txp:php>
and here’s the snippets code:
; Content-type: text/html
<txp:output_form form="sys_variables" />
<txp:smd_article_event section='calendar' limit="99999" from='<txp:smd_cal_now format="%Y-%m-%d 00:00:00" now=''<txp:variable name="date" />'' />' to='<txp:smd_cal_now format="%Y-%m-%d 23:59:59" now=''<txp:variable name="date" />'' />'>
<!-- Status Indicators -->
<p>
<strong><txp:if_custom_field name="Event Status" value="New">New </txp:if_custom_field></strong>
<strong><txp:if_custom_field name="Event Status" value="Cancelled">Cancelled </txp:if_custom_field></strong>
<strong><txp:if_custom_field name="Event Status" value="Moved">Moved to <txp:custom_field name="Event Moved Date" /> </txp:if_custom_field></strong>
<strong><txp:title /></strong><br />
<txp:body />
</p>
</txp:smd_article_event>
When viewing the page with the included snippet I keep getting the following errors:
Tag error: <txp:php> -> Warning: include(): php_network_getaddresses: getaddrinfo failed: No such host is known. while parsing form “calendar” on page “default”
Tag error: <txp:php> -> Warning: include(http://example.com/calendar/?rah_external_output=db_events): failed to open stream: php_network_getaddresses: getaddrinfo failed: No such host is known. while parsing form “calendar” on page “default”
Tag error: <txp:php> -> Warning: include(): Failed opening 'http://example.com/calendar/?rah_external_output=db_events' for inclusion (include_path='.;C:\php\pear') while parsing form “calendar” on page “default”
I’ve also noticed that that the snippets text isn’t being escaped
Last edited by Algaris (2013-07-10 22:52:46)
Offline
#103 2013-03-07 15:10:40
Re: rah_external_output
What happens if you use <txp:php>echo file_get_contents('http://cms.truroschool.com/calendar/?rah_external_output=db_events');</txp:php>
?
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
#104 2013-03-07 15:35:06
- Algaris
- Member
- From: England
- Registered: 2006-01-27
- Posts: 548
Re: rah_external_output
I then get these errors.
Tag error: <txp:php> -> Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: No such host is known. while parsing form “calendar” on page “default”
Tag error: <txp:php> -> Warning: file_get_contents(http://example.com/calendar/?rah_external_output=db_events): failed to open stream: php_network_getaddresses: getaddrinfo failed: No such host is known. while parsing form “calendar” on page “default”
One less than before. Maybe that’s a step in the right direction?
Last edited by Algaris (2013-07-10 22:53:22)
Offline
#105 2013-03-07 16:36:11
Re: rah_external_output
Algaris wrote:
Maybe that’s a step in the right direction?
Yes, but not in terms of the error. The error and issue is still the same; the function change doesn’t solve it. But, include()
is the wrong function for anything network related and changing it to something else even to filesystem functions is better.
Anyway, as the error says the host name is unknown. In other words, your server can not resolve IP address for cms.truroschool.com
. This could be caused by a DNS error or something of that kind.
Offline
#106 2013-03-07 18:10:31
- Algaris
- Member
- From: England
- Registered: 2006-01-27
- Posts: 548
Re: rah_external_output
Thank you. I’ll have a chat with the IT Department who set the servers up.
Onto my second issue, do you have any advice on escaping the displayed contents? At the moment I’m getting things like this:
Boys’ Hockey: U15 v Plymouth College
(A) 3.15pm
instead of:
Boys’ Hockey: U15 v Plymouth College
(A) 3.15pm
Last edited by Algaris (2013-03-07 18:10:56)
Offline
#107 2013-03-07 18:21:59
Re: rah_external_output
Algaris wrote:
Onto my second issue, do you have any advice on escaping the displayed contents?
Not escaping, but encoding. The content is in UTF-8, but you’ve been sending it as ISO-8859-1. Basically you have a content-type header set without a charset information, and your server is configured to default sending content in ISO-8859-1.
You can solve that by either adding charset to the header line definition you have in your rah_external_output snippet, or you could as well remove the line. Snippets default to HTML sent as UTF-8. You will also be able to use a file extension (rah_eo accepts and can map extensions json, js. xm, css, txt, html) to set the content type.
Last edited by Gocom (2013-03-07 18:28:44)
Offline
#108 2013-03-08 10:14:25
- Algaris
- Member
- From: England
- Registered: 2006-01-27
- Posts: 548
Re: rah_external_output
I’m always getting those mixed up. Thank you for your help I’ve fixed the encoding problem by changing the header line.
Offline