Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
Pagination within linklist
How to make pagination among links list?
Providing help in hacking ATM! Come to courses and don’t forget to bring us notebook and hammer! What for notebook? What a kind of hacker you are without notebok?
Offline
#2 2008-01-08 22:04:44
- guiguibonbon
- Member
- Registered: 2006-02-20
- Posts: 296
Re: Pagination within linklist
What do you mean? You must be having a page with nothing but links then, i reckon (e.g. no article) ?
In such case you’re going to have to use php. This would display the pages.
<txp:php>
global $pretext;
$limit = 10; // change to the number of links to display per page
echo linklist(array(
'break' => '', //put the values of the attributes you would have used for the linklist tag
'category' => '',
'form' => 'plainlinks',
'label' => '',
'labeltag' => '',
'wraptag' => '',
// DON'T CHANGE BELOW THIS.
'limit'=>$limit,
'offset'=>($pg)? ($pretext['pg']*$limit) + 1 : ''
));
</txp:php>
This way you can browse through your links by adding a pg variable to the url. If for instance you are using an empty section called ‘links’; the url would be www.mysite.com/links/?pg=2
to see the second page. Making a list of those pages is a whole other issue; and would require a plugin. Either code them manually, depending on the number of links you have and update that every time you need an additional page, or post a resquest in the Plugin Request sub-forum.
Last edited by guiguibonbon (2008-01-08 22:06:04)
Offline
Re: Pagination within linklist
It seems that tag <txp:linklist />
doesn’t have “offset” attr :(
Providing help in hacking ATM! Come to courses and don’t forget to bring us notebook and hammer! What for notebook? What a kind of hacker you are without notebok?
Offline
Re: Pagination within linklist
I think it does now ( r2718 ) but you will need SVN or wait for v4.0.6
Last edited by thebombsite (2008-01-10 00:01:12)
Stuart
In a Time of Universal Deceit
Telling the Truth is Revolutionary.
Offline
Re: Pagination within linklist
Ouch.. I’ve done the listing with offset but how to make textpattern load ob1_pagination?
Little editted code:
<txp:php>
global $pretext;
$limit = 2; // change to the number of links to display per page
echo linklist(array(
'break' => '', //put the values of the attributes you would have used for the linklist tag
'category' => '',
'form' => 'Links',
'label' => '',
'labeltag' => '',
'wraptag' => '',
// DON'T CHANGE BELOW THIS.
'limit'=>$limit,
'offset'=>$pretext['pg'] ? ($pretext['pg']-1)*$limit : ''
));
echo $pretext['pg']; //just for debugging
</txp:php>
And some notice – i paste this code into article, not presentation. And everything loke nice – when i add ?pg=2
to the url it skippes right amount of links in the link list. But I’m stark with calling txp’s pagination function. I think it looks for some parametr from article list wich is absent in link list.
Providing help in hacking ATM! Come to courses and don’t forget to bring us notebook and hammer! What for notebook? What a kind of hacker you are without notebok?
Offline
Re: Pagination within linklist
The regular pagination won’t work with linklist as it doesn’t count amount of rows in the txp_link with specific category. So you will be need extra query or something to bring on the information that how many links there is in total. Like this:
<txp:php>
global $pretext;
$count = getCount("txp_link");
if($pretext['c']) {
$where = "Category = '".$pretext['c']."'";
$count = getCount("txp_link", $where);
}
$showing = gps('pg')*10;
$prev = gps('pg')-1;
$next = gps('pg')+1;
echo (gps('pg') && 1 < gps('pg')) ? '<a href="?pg='.$prev.'">Prev</a>' : 'Prev';
echo ($showing<$count OR $showing == $count) ? '<a href="?pg='.$next.'">Next</a>' : 'Next';
</txp:php>
Cheers!
Last edited by Gocom (2008-01-10 09:57:24)
Offline
Re: Pagination within linklist
Something happened and now it’s shoing error:
Parse error: syntax error, unexpected ‘&’, expecting T_STRING or T_VARIABLE or ‘$’ in /home/u78707/uromax.ru/www/textpattern/publish/taghandlers.php(2807) : eval()’d code on line 6
The whole article code:
<notextile>
<txp:php>
global $pretext;
$limit = 2; // change to the number of links to display per page
echo linklist(array(
'break' => '', //put the values of the attributes you would have used for the linklist tag
'category' => '',
'form' => '',
'label' => '',
'labeltag' => '',
'wraptag' => '',
// DON'T CHANGE BELOW THIS.
'limit'=>$limit,
'offset'=> ''
));
echo $pretext['pg']; //just for debugging
</txp:php>
</notextile>
Last edited by the_ghost (2008-01-10 11:06:48)
Providing help in hacking ATM! Come to courses and don’t forget to bring us notebook and hammer! What for notebook? What a kind of hacker you are without notebok?
Offline
#8 2008-01-10 14:43:32
- guiguibonbon
- Member
- Registered: 2006-02-20
- Posts: 296
Re: Pagination within linklist
Hang tight; I’m making a plugin.
Offline
#9 2008-01-11 20:14:53
- guiguibonbon
- Member
- Registered: 2006-02-20
- Posts: 296
Re: Pagination within linklist
Here is the plugin.
Use like this, if you want only links from the textpattern category to display, for instance :
<txp:php>
global $pretext;
extract($pretext);
$limit = 3; // change to the number of links to display per page
echo linklist(array(
'category' => 'textpattern',
'form' => 'Links',
'limit'=>$limit,
'offset'=>($pg)? (($pg - 1) * $limit) : ''
));
echo n.gbo_paginate_anything(array(
'pageby' => $limit,
'category' => 'textpattern',
'what' => 'link'
));
</txp:php>
Offline
#10 2008-01-16 22:07:21
- chizet
- New Member
- Registered: 2007-09-09
- Posts: 7
Re: Pagination within linklist
Hey ghost, can we see how you are using this? I’m interested in doing something similar but haven’t seen anyone else do it.
Offline
Pages: 1