Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2009-12-21 12:06:07

geoff777
Plugin Author
From: Benarrabá Andalucía Spain
Registered: 2008-02-19
Posts: 282
Website

Cookies - PHP & TXP:Variables

Hi,

I’ve been looking at chs_cookies as a way of handling cookies in a <txp> style tag.

Unfortunately it looks neglected and doesn’t work with <txp:else /> and sets only session cookies unless you fiddle with the plugin code.

So I look to PHP … using something like this for a user to set their own limit for articles shown on the frontpage.

<txp:php> if(isset($_COOKIE['limit'])) $limit = $_COOKIE['limit']; else $limit = 20; <?php>

I know txp tags all equate to a equivalent php function … I’d like to set a <txp:variable /> to = $limit
Can someone give a code example of setting a <txp:variable/> in PHP

Thanks


There are 10 types of people in the world: those who understand binary, and those who don’t.

Offline

#2 2009-12-21 12:40:21

wet
Developer Emeritus
From: Schoerfling, Austria
Registered: 2005-06-06
Posts: 3,376
Website GitHub Mastodon

Re: Cookies - PHP & TXP:Variables

Like so:

<txp:php> 
if(isset($_COOKIE['limit'])) $limit = $_COOKIE['limit']; else $limit = 20; 
variable(array('name' => 'limit', 'value' => $limit));
</txp:php>

Offline

#3 2009-12-21 13:10:21

geoff777
Plugin Author
From: Benarrabá Andalucía Spain
Registered: 2008-02-19
Posts: 282
Website

Re: Cookies - PHP & TXP:Variables

Great!!

Thanks Robert

Merry Xmas – Happy Holidays


There are 10 types of people in the world: those who understand binary, and those who don’t.

Offline

Board footer

Powered by FluxBB