Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2009-02-03 17:43:20

jpeacock
New Member
Registered: 2008-08-26
Posts: 7

php within article_custom for offset?

Hi all,
Is there any way to use php to output the offset for article_custom?
The “Older” tag towards the bottom picks up the correct variable, but i’m not sure if php within tags is stripping the variable. It works if I use a static number for the offset, but not a php variable. This is what I have but it doesn’t seem to do anything.

<txp:article_custom form="dailydose" category="Daily-Dose"
<txp:php>
$o=$_GET['o'];
$o+=10;
echo "offset='$o'";
</txp:php>

limit="10" />

<txp:php>
$o = $_GET['o'];
$o += 10;
echo "<a href='?o=".$o."'>Older</a>";
</txp:php>

Last edited by jpeacock (2009-02-03 17:52:15)

Offline

#2 2009-02-03 18:40:35

jm
Plugin Author
From: Missoula, MT
Registered: 2005-11-27
Posts: 1,746
Website

Re: php within article_custom for offset?

You can’t throw <txp:php> in the middle of an article_custom. You need to use it’s function:

$offset = gps('o') + 10;
echo article_custom(array(
    'form' => 'dailydose',
    'category' => 'Daily-Dose',
    'limit' => 10,
));

Offline

#3 2009-02-03 18:46:47

jpeacock
New Member
Registered: 2008-08-26
Posts: 7

Re: php within article_custom for offset?

Awesome, thanks. Just what I was looking for.

Offline

#4 2009-02-04 05:01:45

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

Re: php within article_custom for offset?

In Textpattern 4.0.7+ you could also take advantage of attribute parsing:

<txp:article_custom form="dailydose" category="Daily-Dose" 
offset='<txp:php>echo gps('o') + 10;</txp:php>' limit="10" />

Last edited by wet (2009-02-04 05:01:59)

Offline

Board footer

Powered by FluxBB