Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2009-10-18 17:42:37
- Kelon
- Member
- Registered: 2009-10-18
- Posts: 16
3 newer titles and 3 older titles than the 3 on show
Hi, hope you’re well and thanks for stopping by.
I’m very new to Textpattern though not to the internet or to coding generally, so my first ever Textpattern site is almost ready to take to the remote server and I’m pretty proud of it though I say so myself – textpattern is really rather good isn’t it… anyway, this one thing I haven’t been able to track down, though it must surely have been done or asked before… and I apologise for my lack of detective skills. Anyway, enough preamble..
Question:
My page displays 3 articles c/w “newer” “older” links at the bottom.
In the side bar I’d like to list 6 other article titles in full.
3 previous ones (newer) and 3 that are older.
The default is to show older ones.
I’ve used: <txp:article_custom limit=“3” offset=“3” wraptag=“ul” break=“li”><txp:permlink><txp:title /></txp:permlink></txp:article_custom> which shows older ones if present.
I am stumped as to how to show the previous 3, newer than the three displayed in the main display area of the page. I’m sure it’s blindingly obvious… just my newby blindness.
Thanks for your understanding and patience.
Last edited by Kelon (2009-10-18 17:44:01)
Offline
#2 2009-10-18 17:51:11
- Kelon
- Member
- Registered: 2009-10-18
- Posts: 16
Re: 3 newer titles and 3 older titles than the 3 on show
“Doh… offset=-3 does work… I just need to exception out the home page which has awesome issues (understandably) with this setting…. is this the right way.. or me being a makeshift programmer :)”
Strike that I’m talking rubbish… doesn’t work. Worth trying mad ideas.
Last edited by Kelon (2009-10-18 17:57:26)
Offline
Re: 3 newer titles and 3 older titles than the 3 on show
Another mad idea, but if you don’t get a more sensible suggestion, here’s a thought:
Fool an article
tag into showing newer articles than the current context indicates by temporarily changing the value of the global $pretext['pg']
. Then change it back again after you’ve displayed the articles you want. Something like this (untested):
<txp:php>
global $pretext;
if ($pretext['pg'] > 1) {
$pretext['pg'] --;
$atts = array(
'limit' => 3,
'wraptag' => 'ul',
'break' => 'li',
);
$thing = '<txp:permlink><txp:title /></txp:permlink>';
echo article($atts, $thing);
$pretext['pg'] ++;
}
</txp:php>
BTW I think you want article
and not article_custom
for your list of older articles in the sidebar. Or is article_custom
working correctly when you’re not on the first page?
Code is topiary
Offline
#4 2009-10-18 21:22:15
- Kelon
- Member
- Registered: 2009-10-18
- Posts: 16
Re: 3 newer titles and 3 older titles than the 3 on show
Works a treat! (not thoroughly tested it, I’ll admit). Thank you Jeff…
Since posting, I’ve been checking out the scope of variables <txp:variable /> and concluding that I couldn’t persuade it to pass the variable I thought I needed from a to b….. so had come to the conclusion I’d end up using <txp:php> cos I’m comfy with php, though appreciated I’d need to understand a bit more about Textpattern. Who knows if I’d have ever worked out a “fool it” was needed, saved me hours of frustration you have, very much appreciated.
Been checking out some well designed blogs I know that use textpattern to see if they’re doing it.. and.. well, this doesn’t seem to be out there… that’s a bit disturbing. I’m wondering idly why…
Oh and thank you too for the <txp:article> not <txp:article_custom>… I’ve not had enough articles in my test to really appreciate it wasn’t actually working in the way I thought.
Much appreciated. Thank you again. Regards.
Last edited by Kelon (2009-10-18 21:26:29)
Offline