Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#101 2012-10-08 23:22:55

robbiia
Member
From: New York
Registered: 2012-08-05
Posts: 8
Website

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: 448

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 &nbsp;</txp:if_custom_field></strong>
		<strong><txp:if_custom_field name="Event Status" value="Cancelled">Cancelled &nbsp;</txp:if_custom_field></strong>
		<strong><txp:if_custom_field name="Event Status" value="Moved">Moved to <txp:custom_field name="Event Moved Date" /> &nbsp;</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

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 7,649
Website

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.org | hblack.net | LABS | State Machines | Respbublika! | NeMe @ github
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: 448

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

Gocom
Plugin Author
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

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: 448

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

Gocom
Plugin Author
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

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: 448

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

#109 2013-04-23 07:53:58

Gocom
Plugin Author
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: rah_external_output

v1.0.2 released. Changes:

  • Fixed: PHP namespace compatibility.
  • Changed: Under Textpattern 4.6.0-dev adds the ‘View’ link to the new action bar.
  • Improved: Internal clean up.
  • Improved: Use Textpattern’s assigned flags to ensure future compatibility.
  • Improved: Creating preferences to the memory isn’t necessary.

More info and downloads

Offline

#110 2013-10-09 09:40:16

txpdevcoder
Member
Registered: 2012-06-07
Posts: 58

Re: rah_external_output

Hey,

I have a problem with rah_external output. Ive used it to generate an xml feed that i pull into another website as a kind of a featured blog posts. It worked great for a long but now we have updated our blog to use rss_unlimited_catagories. Unfourtunatly the rss_unlimited_catagories tags do not work inside rah_external_output

If i switch it to a standard txp:article tag it works fine, but is obviously not seeing the categories I want it too.

My feed looks like this. Am i missing something?

<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" >
<channel>
<generator>http://textpattern.com/</generator>
<title><txp:site_name /></title>
<link><txp:link_to_home /></link>
<pubDate><txp:php>echo strftime( "%a, %d %b %G %T %Z" );</txp:php></pubDate>
<atom:link href="<txp:site_url/>?rah_external_output=featuredfeed" rel="self" type="application/rss+xml" />
<txp:rss_unlimited_categories_article_list limit="4" category="featuredfeed">
<item>
<title><txp:title /></title>
<description>
<![CDATA[
<txp:excerpt />
]]>
</description>
<link><txp:permlink /></link>
<pubDate><txp:posted format="%a, %d %b %G %T %Z" /></pubDate>
<dc:creator><txp:author /></dc:creator>
<guid><txp:permlink /></guid>
</item>
</txp:rss_unlimited_categories_article_list>
</channel>
</rss>

Offline

Board footer

Powered by FluxBB