Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#25 2009-07-05 19:01:04

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

Re: rah_external_output

FireFusion wrote:

I can’t get this working with adi_gps no matter where i put it in the load order. Am trying to assign a category for my slideshow through get variable.

  1. Make sure that the GET variable is assigned into the slideshow script (and into the rah_external_output’s url).
  2. Make sure that adi_gps is loaded before rah_external_output kills (load order is higher).
  3. Make sure that adi_gps doesn’t use $pretext or etc. TXP’s global arrays. We are not on section page, so those aren’t set. Plugins are loaded before TXP’s $pretext global.

Last edited by Gocom (2009-07-05 19:02:39)

Offline

#26 2009-07-05 20:01:52

FireFusion
Member
Registered: 2005-05-10
Posts: 698

Re: rah_external_output

1. Done
2. Done
3. Nope

/*
	adi_gps - Extract GET & POST variables

	Written by Adi Gilbert

	Released under the GNU General Public License

	Version history:
	0.1		- initial release

*/

function adi_gps($atts) {

	extract(lAtts(array(
		'name'			=> '',	// a single GET/POST var
		'new'			=> '',	// new variable name
		'txpvar'		=> '1',	// set as a TXP variable or not
		'post'			=> '0',	// extract POST vars or not
		'quiet'			=> '0',	// return value or not
		'global'		=> '1', // make vars global or not
		'escape'		=> '',	// escape HTML entities or not
		'decode'		=> '0',	// perform a urldecode or not
		'list'			=> '0', // list variable names and values
		'debug'			=> '0',
	), $atts));

	if ($name == '') { // no single var specified, so all vars extracted
		$quiet = 1; // force quiet mode
		$new = ''; // disable var rename
		$get_list = array_keys($_GET);
		$post ?
			$post_list = array_keys($_POST) : $post_list = array();
		$name_list = array_merge($get_list,$post_list);
	}
	else
		$name_list[] = $name;

	$debug_list = 'adi_gps variables';
	foreach ($name_list as $index => $name) {
		$value = gps($name); // extract value
		if ($decode) // convert %chars
			$value = urldecode($value);
		if ($escape == 'html') // encode chars (e.g. ampersand becomes &)
			$value = htmlentities($value);
		if ($new) // rename var (single var mode only)
			$name = $new;
		if ($txpvar) // create TXP variable
			parse('<txp:variable name="'.$name.'" value="'.$value.'"/>');
		if ($global) // make the variable global
			$GLOBALS[$name] = $value;
		if ($list)
			$debug_list .= ":$name=$value";
	}

	if ($debug) {
		echo 'SUPPLIED ATTRIBUTES:<br/>';
		dmp($atts);
		echo "GET VARS:<br/>";
		dmp($_GET);
		echo "POST VARS:<br/>";
		dmp($_POST);
		echo "ADI_GPS VAR LIST:<br/>";
		dmp($name_list);
		echo "ALL TXP VARS:<br/>";
		dmp($GLOBALS['variable']);
	}

	if ($list)
		return $debug_list.'<br/>';
	else
		if ($quiet) // don't report value
			return '';
		else // return value
			return $value;
}

:)

Last edited by FireFusion (2009-07-05 20:02:16)

Offline

#27 2009-08-07 19:15:23

johnstephens
Plugin Author
From: Woodbridge, VA
Registered: 2008-06-01
Posts: 999
Website

Re: rah_external_output

This is an awesome plugin. One warning: External output doesn’t work if your site’s production status is set to “Debugging”. I just spent 45 minutes trying to chase down a non-existent js bug or plugin collision with the site in “Debugging”— when I switched it to “Testing” or “Live” it worked perfectly again (this occurred in Textpattern 4.0.8).

Offline

#28 2009-08-07 23:12:39

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

Re: rah_external_output

johnstephens wrote:

This is an awesome plugin. One warning: External output doesn’t work if your site’s production status is set to “Debugging”. I just spent 45 minutes trying to chase down a non-existent js bug or plugin collision with the site in “Debugging”— when I switched it to “Testing” or “Live” it worked perfectly again (this occurred in Textpattern 4.0.8).

If you use the plugin, you might get some “errors” specially in the Debugging mode. This is caused by the fact that the plugin outputs the content in a non section/any context. All plugins/code/tags that hook or do something that requires section or something similiar, might cause problems.

What is the error message?

Last edited by Gocom (2009-08-07 23:13:15)

Offline

#29 2010-02-11 19:21:53

lovetheg
New Member
Registered: 2010-02-11
Posts: 5

Re: rah_external_output

Hi,
I’d like to use this plugin to display the dynamic navigation bar I use in my textpattern pages on external (static) php pages elsewhere in the same domain. So I’ve copied the form code and made an external snippet, which then looks OK through URL given via the ‘view’ link in the plugin.

My question is, how do I then pull that code into my php file, I tried…

<?php include($DOCUMENT_ROOT . "http://my-txp-site.tld/?rah_external_output=nav-form"); ?>

…as suggested previously in this thread but it did seem not work. and also…

<?php include("http://my-txp-site.tld/?rah_external_output=template1"); ?>

…still no joy? Can you give me some help as I’m completely stuck!

Thanks,
Dan

Offline

#30 2010-02-14 16:44:21

lovetheg
New Member
Registered: 2010-02-11
Posts: 5

Re: rah_external_output

Bump! Can anyway help with my previous post? Would really like to use this.
Thanks muchly.

Offline

#31 2010-02-15 08:04:22

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

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

#33 2010-02-15 10:33:28

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

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

#35 2010-02-15 11:49:11

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

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

Board footer

Powered by FluxBB