Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Re: rah_external_output
Hi lovetheg,
Can you post the code included in your rah_external_output=template1?
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
#32 2010-02-15 09:54:31
- lovetheg
- New Member
- Registered: 2010-02-11
- Posts: 5
Re: rah_external_output
Sure, this is one of them…
<txp:article_custom section="blog" limit="3" form="blog_latest">
<div class="entry">
<p class="date"><txp:posted format="%d/%m/%y" /></p>
<p class="time"><txp:posted format="%H:%M" /></p>
<p class="text"><txp:permlink><txp:title /></txp:permlink></p>
</div>
</txp:article_custom>
Regards,
Dan
Offline
Re: rah_external_output
and the form blog_latest? … which might not be needed.
maybe you should try:
<txp:article_custom section="blog" limit="3">
<div class="entry">
<p class="date"><txp:posted format="%d/%m/%y" /></p>
<p class="time"><txp:posted format="%H:%M" /></p>
<p class="text"><txp:permlink><txp:title /></txp:permlink></p>
</div>
</txp:article_custom>
Last edited by colak (2010-02-15 10:34:15)
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
#34 2010-02-15 10:55:27
- lovetheg
- New Member
- Registered: 2010-02-11
- Posts: 5
Re: rah_external_output
Sorry, mistake in above code, should be…
<txp:article_custom section="blog" limit="3">
<div class="entry">
<p class="date"><txp:posted format="%d/%m/%y" /></p>
<p class="time"><txp:posted format="%H:%M" /></p>
<p class="text"><txp:permlink><txp:title /></txp:permlink></p>
</div>
</txp:article_custom>
And from the external file I try to call it unsuccessfully with…
<?php include($DOCUMENT_ROOT . "http://www.mysite.com/?rah_external_output=body-latest"); ?>
Or…
<?php include 'http://www.mysite.com/?rah_external_output=blog-latest'; ?>
Or…
<?php include '/var/www/vhosts/mysite.com/httpdocs/?rah_external_output=blog-latest'; ?>
None of which worked.
Offline
Re: rah_external_output
lovetheg wrote:
None of which worked.
On the server that you use the include, you need to have url_fopen set to true and outgoing connections have to be allowed. Also server must allow PHP to access the site from outside.
<?php
If the place where you are including the script is within TXP, you might want to use <txp:php> instead PHP closing tags.
include
Because included file isn’t a PHP code within the file system, it’s better to use file function instead include which is used to evaluate code.
$DOCUMENT_ROOT […] /var/www/vhosts/mysite.com/httpdocs/
Includes from file system won’t transfer GET nor POST vars. If you want to access the file from file system, you have to use a script that defines variables required by TXP.
[…]
<txp:php>
echo file_get_contents(
'http://www.mysite.com/?rah_external_output=blog-latest'
);
</txp:php>
Last edited by Gocom (2010-02-15 11:49:39)
Offline
#36 2010-02-15 14:40:13
- lovetheg
- New Member
- Registered: 2010-02-11
- Posts: 5
Re: rah_external_output
Thanks Jukka,
1. In my server php.ini, this is set: ‘allow_url_fopen = On’
2. The script is not within TXP, it is a separate file on the same domain.
3. This finally got it working…
<?php echo file_get_contents('http://www.mysite.com/?rah_external_output=blog-latest'); ?>
That’s awesome – this opens up some crazy useful uses for TXP.
Offline
Offline
Re: rah_external_output
For those baronial types using jsp for development, the equivalent jsp code of the php in message #36 for pulling rah_external_output into their pages is:
<c:import url="http://www.mysite.com/">
<c:param name="rah_external_output" value="XXX"/>
</c:import>
Where XXX is the name your gave your snippet in the rah_external_output admin.
Hope that is of help to people.
Phil
Offline
Re: rah_external_output
Thank you for sharing Phil :-)
Maybe some fetching examples won’t hurt. Let’s see; In cURL including can be expanded on an idea like:
<txp:php>
$curl = curl_init();
curl_setopt ($curl, CURLOPT_URL, 'http://example.com/?rah_external_output=MyScriptName');
curl_setopt ($curl, CURLOPT_RETURNTRANSFER, 1);
echo curl_exec ($curl);
curl_close ($curl);
</txp:php>
cURL is ideal if communicating with the server is required; cURL mimics a real web browser and supports multiple protocols and can send headers.
Example number two. If TXP is used, including can be done with plugins. That way there is no need to look raw PHP. Here is an example that uses rah_function. It tries to include contents of the URL with file_get_contents():
<txp:rah_function call="file_get_contents" url="http://example.com/?rah_external_output=MyScriptName" />
Last edited by Gocom (2010-02-16 16:22:15)
Offline
Re: rah_external_output
finally getting around to using this!
i saw an earlier in this thread other people are also using this for ical like applications. the part that i don’t get is how to make it export to a file rather than spit out on the page. i don’t know what i should set for content type, but i imagine it also has something to do with what i put in the presentation form.
BEGIN:VEVENT
DTSTART;VALUE=DATE:20060704
DTEND;VALUE=DATE:20060705
SUMMARY:<txp:body />
X-GOOGLE-CALENDAR-CONTENT-TITLE:<txp:title />
X-GOOGLE-CALENDAR-CONTENT-ICON:http://www.google.com/calendar/images/google-holiday.gif
X-GOOGLE-CALENDAR-CONTENT-URL:<txp:article_image />
X-GOOGLE-CALENDAR-CONTENT-TYPE:image/gif
X-GOOGLE-CALENDAR-CONTENT-WIDTH:276
X-GOOGLE-CALENDAR-CONTENT-HEIGHT:120
END:VEVENT
<txp:rah_external_output name="ical" />
Offline
Re: rah_external_output
just wondering if anyone got a chance to take a look at my post above? thanks
EDIT: sniffing around a bit more i was able to find this tool: <a href=”<txp:site_url />?rah_external_output=ical”>download iCal</a>
this seems to make a file out of things you create with rah external output. the only thing missing is it doesn’t give a file name when the user downloads. this is great for so many uses like m3u playlists is one on the top of my head.
i would suggest adding it to the help file.
Last edited by mrtunes (2010-03-06 21:22:21)
Offline
Re: rah_external_output
Thinking aloud, I wonder whether jukka’s htaccess trick at the end of rah_sitemap would work here too… if so, then you would link to the file name…
TXP Builders – finely-crafted code, design and txp
Online
Re: rah_external_output
I’m using this plugin extensively to cross relate our sites.
I wonder if there is some php I could use to prevent white screens when database is unavailable.
something like
<?php if database available // or if no error
include($DOCUMENT_ROOT . "http://my-txp-site.tld/?rah_external_output=template1");
else;
<p>some content here</p>
?>
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Re: rah_external_output
These are totally just examples. Not tested, probably won’t work.
<?php
$content = file_get_contents('http://www.example.com?rah_external_output=name');
if(
!$content or $content == 'My some error page content here'
)
echo 'Some content here';
else
echo 'hi';
?>
Above example really isn’t error awere at all. With curl you can return the error code. By modifying that example, we can get something like:
<?php
$curl = curl_init();
curl_setopt ($curl, CURLOPT_URL, 'http://example.com/?rah_external_output=MyScriptName');
curl_setopt ($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
$content = curl_exec ($curl);
$data = curl_getinfo($ch);
curl_close ($curl);
if($data['http_code'] != '200')
echo 'Some content here';
else
echo $content;
?>
Last edited by Gocom (2010-03-07 15:58:31)
Offline
Re: rah_external_output
Hi Jukka. Thanks! That was a swift answer. Not sure if it’s working or not (2nd snippet) as it produces database errors.
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline