Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2010-11-29 22:35:15

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,793
Website

Bug? Image context and messy URLs

The global $context variable does not get set correctly for a page such as:

foo.com/?c=bar&context=image

From a quick look through publish.php, I think it’s because preText() isn’t setting this with messy URLs and hence it defaults to article. This includes clean URL schemes that still give a query string, as with a category page within a section.

Among other things this means if_category type="image" won’t work correctly.

[Discovered by someone trying to implement my core image tags demo and finding it didn’t work correctly with their permanent link mode.]


Code is topiary

Offline

#2 2010-11-30 21:33:28

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,793
Website

Re: Bug? Image context and messy URLs

Patch submitted to txp-dev list.


Code is topiary

Offline

#3 2010-12-09 13:36:25

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,793
Website

Re: Bug? Image context and messy URLs

Workaround while we’re waiting for the official fix. If you need to use if_category type="image" or some other code that depends on something other than the default (article) context, add this above the code:

<txp:php>
       if ( $gps_context = gps('context') )
       {
               global $context;
               $context = $gps_context;
       }
</txp:php>

What this does: check if there is a messy URL parameter named “context”, and if so, assign its value to the global $context variable.

Edit: Turns out this can be a problem in article context too. The version below will cover both cases:

<txp:php> // Workaround for $context bug in Txp 4.3.0 messy URL mode
	global $context;
	$gps_context = gps('context');
	$context = $gps_context ? $gps_context : 'article';
</txp:php>

Last edited by jsoo (2011-01-10 23:53:52)


Code is topiary

Offline

Board footer

Powered by FluxBB