Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

smartypaginate - back to list

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Add-ons
View previous topic :: View next topic  
Author Message
thiebo
Smarty Pro


Joined: 16 Jan 2005
Posts: 144
Location: Paris

PostPosted: Sun May 07, 2006 10:01 am    Post subject: smartypaginate - back to list Reply with quote

Hello,

I have used smartypagination to paginate the results from a mysql query. The query is pretty complex so users can fill out several research criteria. As a result, the user gets a list of items corresponding to its criteria with keywords.

Each item contains a link to a page with the full result (results are texts, sometimes even long texts so I can't put full results in the list of results which only shows keywords).

Once user is on that page with the text and wants to go back to the list, you can click on the "back" button of the browser, which then shows a message saying that the POST will be resent and "do you really want to resend ?".

Is there any way to add a link on that page with full results saying "back to list" ?

I put the exact query in $_SESSION['query'] but of course I can't use that as $_GET for the code containing the query and the pagination code.

I someone has an idea...

Thanks a lot !
Back to top
View user's profile Send private message Visit poster's website
Dieter
Smarty Rookie


Joined: 08 Sep 2003
Posts: 9

PostPosted: Sun May 07, 2006 12:20 pm    Post subject: Reply with quote

set your form method to GET instead of POST?
Back to top
View user's profile Send private message
thiebo
Smarty Pro


Joined: 16 Jan 2005
Posts: 144
Location: Paris

PostPosted: Wed May 10, 2006 8:24 pm    Post subject: Reply with quote

Hi,
thanks for your reply, but doing that causes a smartyPaginate problem : first page of results is fine but clicking to the next page causes an error :

"SmartyPaginate setLimit: limit must be an integer."

Which is funny because the number of results per page is put in the $_SESSION['number'].

[php:1:df47b0d685]$nombre = $_GET['nombre'] ;

if ($_GET)
{$_SESSION['nombre'] = $nombre;
}
else {
$nombre = $_SESSION['nombre'];
}

SmartyPaginate::setLimit($_SESSION['nombre']);
[/php:1:df47b0d685]

Echoing $_SESSION['number'] on the first page of results is OK, but that $_SESSION['number'] is lost when I change POST to GET...

I haven't found the reason for that yet. I'll try it out because of course changing POST to GET is the right answer to my problem.

Regards,
Back to top
View user's profile Send private message Visit poster's website
Dieter
Smarty Rookie


Joined: 08 Sep 2003
Posts: 9

PostPosted: Thu May 11, 2006 11:47 pm    Post subject: Reply with quote

you're mixing $_GET['nombre'] and $_GET['number'] ...

the error says 'number' but you assign 'nombre' ?

anyway, i'd solve it like this:

[php:1:ac2660f999]
//do we have a number specified in the URL?
if ($_GET['number'])
{
$number = intval($_GET['number']);
}
//has there been a number assigned to SmartyValidate?
elseif (SmartyPaginate::getLimit())
{
//use the current number
$number = SmartyPaginate::getLimit();
}
else
{
//your default number
$number = 25;
}

SmartyPaginate::setLimit($number);
[/php:1:ac2660f999]
Back to top
View user's profile Send private message
thiebo
Smarty Pro


Joined: 16 Jan 2005
Posts: 144
Location: Paris

PostPosted: Fri May 12, 2006 7:15 am    Post subject: Reply with quote

Hello Dieter,

Thanks for your reply. The confusing between $number and $nombre was only in my previous message, not in my code.

The code you propose works fine too and is cleaner than the code I was using, thanks for that.

However, I think that the solution to my problem is the url : the first page, the correct url is sent to the php-script that executes the mysql-query, clicking to the next page, the url is only script.php?next=7 and all the other parameters are lost.

In think smartypaginate contains a some url functions, I'll try that way or... put the query in $_SESSION. This last solution is probably the cleanest.

I'll post the solution here if and once I have found it.

Regards,
Back to top
View user's profile Send private message Visit poster's website
Dieter
Smarty Rookie


Joined: 08 Sep 2003
Posts: 9

PostPosted: Fri May 12, 2006 10:13 am    Post subject: Reply with quote

can't you use $_SERVER['QUERY_STRING'] and SmartyPaginate::setUrl('yourscript.php')?

[/php]
Back to top
View user's profile Send private message
thiebo
Smarty Pro


Joined: 16 Jan 2005
Posts: 144
Location: Paris

PostPosted: Fri May 12, 2006 8:59 pm    Post subject: Reply with quote

Hi again.

@Dieter : when you posted your code for keeping the $number in $_SESSION, I overlooked that that code does not keep $_SESSION['number'] actually. The number of results on the second page is 10... the smartyPaginate default number.

But the idea of using $_SERVER['QUERY_STRING'] and SmartyPaginate::setUrl('yourscript.php') is excellent.

If someone is interested, here's what I did :

[php:1:80e74b2aad]$varDemande = ($_SERVER['QUERY_STRING']);

SmartyPaginate::reset();
SmartyPaginate::connect();
SmartyPaginate::setLimit($nombre);

if($_GET){
SmartyPaginate::setUrl('listeactes.php?'.$varDemande);
}else{
SmartyPaginate::setUrl('listeactes.php');
}

[/php:1:80e74b2aad]

and it works great !!!

Thanks for all your help, Dieter.
Back to top
View user's profile Send private message Visit poster's website
Dieter
Smarty Rookie


Joined: 08 Sep 2003
Posts: 9

PostPosted: Sat May 13, 2006 12:18 am    Post subject: Reply with quote

de rien
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Add-ons All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP