Forums

Pagination and search form

jack19 09 Feb, 2013
Hello to all,
I have a problem:
Making a custom form for a search in a table ChronoForms and setting:
• Enable Data Displayer: No
• Enable Pagination: bottom
• Limit: 20
When I search the form I correctly returns 20 results and footer pagination and here's the problem:
clicking on the navigation (or later pages. etc..) loses the search string and almost makes me see all the records (paged 20 per page).
For example I want a word and the results of the first page containing the record of the keyword and bottom pagination

Show # 20 (with the drop-down menu)
<< Start <Prev 1 2 3 4 5 6 7 8 9 10 Next> End >>
Page 1 of 24


Now you can click on any navigation links, I returns the full list and the page is:

Show # 20 (with the drop-down menu)
<< Start <Prev 1 2 3 4 5 6 7 8 9 10 Next> End >>
Page 8 of 1653

For two days I can not figure it out.
Do you have any idea?
Best Regards
GreyHead 09 Feb, 2013
Hi Jack,

You have to make sure that the search term is passed on when the form is submitted i.e. the pagination link is clicked. I think that we solved this before, when I have time I'll see if I can hunt the answer down.

Bob
jack19 09 Feb, 2013
Hi Bob,
I hope you will be able to find it.
I am exhausted and I can not make my brain work well. :?
Jack
jack19 12 Feb, 2013
Up.
I searched all over the forum, but I have not found an answer.
No one can give me some help?
😶 😢 :?
Regards.
GreyHead 22 Feb, 2013
Hi jack19,

I just built a test form and it appears to work correctly and the pagination keeps the filtered data.

How exactly is your form set up? You said that the Data Displayer is off? Is that correct?

Bob
jack19 22 Feb, 2013
Hi Bob,
Yes, Data Displayer is off.
Making a custom form for a search in a table ChronoForms and setting:
• Enable Data Displayer: No
• Enable Pagination: bottom
• Limit: 20

Regards
GreyHead 24 Feb, 2013
Hi jack19,

If the Data Displayer is off what are you using to display the data? I'm getting confused here :-(

Bob
jack19 25 Feb, 2013
Hi Bob,
The Data Displayer is off, because I did a custom query.
Jack
GreyHead 25 Feb, 2013
Hi Jack,

OK so what is the code (a) for the query and (b) to display the data?

Bob
jack19 25 Feb, 2013
Hi Bob,
WHERE Statement

`titolo` LIKE '%<?php echo $form->data['search']; ?>%'
OR `autore` LIKE '%<?php echo $form->data['search']; ?>%' OR `cf_id` LIKE '%<?php echo $form->data['search']; ?>%'


and Custom Code action
<h1>Elenco Libri</h1>
<?php
// start ord
$img="";
if (Jrequest::getVar('direction','','get')=="") {
$ord="asc";
}
if (Jrequest::getVar('direction','','get')=="desc") {
$ord="asc";
$img="desc";
}
if (Jrequest::getVar('direction','','get')=="asc") {
$ord="desc";
$img="asc";
}
// end ord
?>
 
<table class="tableMRL" style="width: 100%" id="db_multi_record_loader">
<thead>
<tr>
<th style="width: 8%" class="col1 cell"><a class="order_link direction_asc"
 href="index.php?option=com_chronoforms&chronoform=Consultazione&order=cf_id&direction=<?php echo $ord; ?>"
>N° <?php if (Jrequest::getVar('order','','get')=="cf_id"){
echo "<img src=\"images/sort_".$img.".png\" alt=\"\"  />"; } ?></a></th>
<th style="width: 20%" class="col2 cell"><a class="order_link direction_asc"
 href="index.php?option=com_chronoforms&chronoform=Consultazione&order=titolo&direction=<?php echo $ord; ?>
">Titolo <?php if (Jrequest::getVar('order','','get')=="titolo")
{echo "<img src=\"images/sort_".$img.".png\" alt=\"\"  />"; } ?></a></th>
<th style="width: 20%" class="col3 cell"><a class="order_link" 
href="index.php?option=com_chronoforms&chronoform=Consultazione&order=autore&direction=<?php 
echo $ord; ?>">Autore 
<?php if (Jrequest::getVar('order','','get')=="autore"){
echo "<img src=\"images/sort_".$img.".png\" alt=\"\"  />"; } ?></a></th>
<th style="width: 8%" class="col1 cell"><a class="order_link direction_asc"
 href="index.php?option=com_chronoforms&chronoform=Consultazione&order=cf_id&direction=<?php echo $ord; ?>"
>Dettagli<?php if (Jrequest::getVar('order','','get')=="cf_id"){
echo "<img src=\"images/sort_".$img.".png\" alt=\"\"  />"; } ?></a></th>
</tr>
</thead>
 
<?php
$bb=$form->data['elenco'];
foreach ($bb as $a) {
echo "<tr class=hover><td class=hover>".$a['cf_id']."</td><td class=hover>".$a['titolo']."
</td><td class=hover>".$a['autore']."</td>
<td class=hover><a class=\"order_link\" 
href=\"index.php?option=com_chronoforms&chronoform=scheda&rec=".$a['cf_id']."\"><img src=images/preview.png alt=\"Anteprima\" /></a>
</td>
</tr>";
}
?>
</table>

Best Regards
GreyHead 26 Feb, 2013
Hi jack19,

Please drag a Debugger action into the On Load event, and post the debug results here.
You should be able to see your data in $form->data['elenco'] if the query is working correctly.

The WHERE clause looks correct, but hard to tell without the rest of the query code.

Bob
jack19 26 Feb, 2013
Hi Bob,
Data Array: 
Array
(
    [option] => com_chronoforms
    [Itemid] => 50
    [chronoform] => RicercaMultipla
    [event] => submit
    [search] => 
    [titolo] => 
    [autore] => Manzoni Alessandro
    [input_submit_2] => Cerca
    [ab785047b6847da916bb42d442bb869e] => 1
    [elenco] => Array
        (
            [0] => Array
                (
                    [cf_id] => 59
                    [cf_uid] => 
                    [cf_created] => 2012-11-27 00:00:00
                    [cf_modified] => 0000-00-00 00:00:00
                    [cf_created_by] => 62
                    [cf_modified_by] => 0
                    [cf_ipaddress] => 
                    [cf_user_id] => 0
                    [nregistroingresso] => 
                    [dataregistrazioneingresso] => 
                    [numerocopie] => 
                    [segnatura] => CM ED  P  71
                    [fondo] => Centro Manzoniano
                    [autore] => Manzoni Alessandro
                    [titolo] => IS ISPOSUS TRADUZIONE IN SARDO-CAMPIDANESE DI ROSARIA SPISSU MELIS, ILLUSTRAZIONI DI GIANNI ARGIOLAS E AUGUSTO LOI
                    [in] => 
                    [acuradi] => 
                    [prefazione] => 
                    [introduzione] => 
                    [periodico] => 
                    [citta] => Casteddu
                    [editore] => Aga Editrice
                    [cm] => 
                    [pagine] => 765, ILL.
                    [data] => 1988
                    [note] => 
                    [recensioni] => 
                    [argomenti] => 
                    [donazione] => 
                    [prezzoacquisto] => 
                    [siglacompilatore] => ND
                    [nomeutente] => 
                    [published] => 1
                )

            [1] => Array ..................... etc

and
Debug Data1.
db_multi_record_loader1. SELECT `elenco`.* FROM `man_chronoforms_data_ins_biblio` AS `elenco` WHERE `autore` LIKE '%Manzoni Alessandro%' LIMIT 0,20 

GreyHead 06 Mar, 2013
Hi jack19,

That all looks good - but it is the first page so there is no problem with that one?

Bob
jack19 07 Mar, 2013
Hi, Bob
I solved with this workaround.
editing the page libraries/joomla/html/pagination.php around line 494, 508, 511 and 526 appendig the string:
."&search=".$_REQUEST['search'];
e.g.
//$data->previous->link	= JRoute::_("&limitstart=".$page);
$data->previous->link	= JRoute::_("&limitstart=".$page."&search=".$_REQUEST['search']);

😑
Regards
GreyHead 07 Mar, 2013
Hi jack19,

That will work OK. Make sure you have a note to re-do the fix if you upgrade Joomla!.

I think that the alternative would probably be to use JavaScript to do the same thing on the page and update all the pagination links.

Bob
jack19 07 Mar, 2013
Hi Bob,
This solution was the fastest at the time. I could not do the same with Javascript.
Jack
This topic is locked and no more replies can be posted.