Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8952083
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:47:47+00:00 2026-06-15T13:47:47+00:00

I´m struggling with the Pagination. I want to use the default functionality. The problem

  • 0

I´m struggling with the Pagination.
I want to use the default functionality.
The problem is that the links of the pagination-buttons (numbers, prev, next) doesn´t work.
I don´t know how to pass the “page:2” in the URL back to the paginator for him to know that he must show/render the table with the next 5 results.
E.g: I click on the “2” for page:2 and the site is going to be refreshed but no result-table is shown at all.

Other Info:
The URL of the input-field is at cakephp/Posts/index. When I click a paginator-button (e.g. prev), the paginator goes to cakephp/Posts/index/page:2.

Here you get the PostsController-code:

class PostsController extends AppController {    
    var $name = 'Posts';
    public $helpers = array('Html', 'Form', 'Js', 'Paginator');
    public $components = array('RequestHandler');
    public $paginate = array(
    'limit' => 5,
    'maxLimit' => 50,
    'order' => array(
        'Post.INCOME' => 'asc',
    ),
);
function index() {
    //debug($this->request->data);
    //var_dump($this->params);
    if(!empty($this->request->data['ajaxSearchAll'])){
        if($this->RequestHandler->isAjax()){
            //$data = $this->Post->find('all', array('conditions' => array('ZIPCODE LIKE' => '%' . $this->data['ajaxSearchAll'] . '%')));
            $posts = $this->paginate('Post', array('ZIPCODE LIKE' => '%' . $this->data['ajaxSearchAll'] . '%')); 
            //$this->set('posts', $data);
            $this->set(compact('posts')); 
            $this->render('SearchAll', 'ajax');         
        }   
    } 
/// GOES ON WITH IRRELEVANT STUFF ///

The following shows the view-file-code of the “search_all.ctp” (The debug-dumps show a proper array how it should be):

<?php $this->paginator->settings = array(
    'limit' => 5,
    'maxLimit' => 25
); 
$this->Paginator->options(array('url' => array('controller' => 'Posts', 'action' => 'index')));
?>
<table>
    <tr>
        <th><?php echo $this->Paginator->sort('CITY', 'Stadt'); ?></th>

        <th><?php echo $this->Paginator->sort('DATE', 'Lieferdatum'); ?></th>
        <th><?php echo $this->Paginator->sort('TIME', 'Lieferzeit'); ?></th>        
    </tr>
    <!-- Hier iterieren wir in einer Schleife durch den $posts Array und geben die Daten des aktuellen Elements aus -->

    <?php foreach ($posts as $post): ?>
    <tr>
        <td><?php echo $this->Html->link($post['Post']['CITY'],"/Posts/view/".$post['Post']['id']); ?></td>
        <td><?php echo $post['Post']['DATE']; ?></td>
        <td><?php echo $post['Post']['TIME']; ?></td>
    </tr>
    <?php endforeach;} ?>
</table>
<?php 
if(!empty($posts)){ 
    echo $this->Paginator->first(__('Erste Seite', true), array('class' => 'disabled'));
    echo " ";
    echo $this->Paginator->prev('« Vorherige Seite', null, null, array('class' => 'disabled'));
    echo " ";
    echo $this->Paginator->numbers();
    echo " ";
    echo $this->Paginator->next('Nächste Seite »', null, null, array('class' => 'disabled'));
    echo " ";
    echo $this->Paginator->last(__('Letzte Seite', true), array('class' => 'disabled'));
} ?>
<?php debug($this->Paginator->params()); 
debug($this->request->params['paging']);
?>

I would be so thankful if anyone of you can solve my problem.

UPDATE 1:
I give you the array of

debug($this->request->params['paging']);

It looks absolutely fine. Do I have to do something with the named parameters? I found nothing suitable in the cookbook 🙁

array(
    'Post' => array(
        'page' => (int) 1,
        'current' => (int) 5,
        'count' => (int) 11,
        'prevPage' => false,
        'nextPage' => true,
        'pageCount' => (int) 3,
        'order' => array(
            'Post.INCOME' => 'asc'
        ),
        'limit' => (int) 5,
        'options' => array(
            'conditions' => array()
        ),
        'paramType' => 'named'
    )
)

UPDATE 2: The code of the index.ctp, where the ajax-search starts. The query and the first page of the paginator are working perfectly. But not the buttons of the paginator at all:

<div id="courierQuery">
    <?php echo $this->Form->create(false, array('type' => 'post', 'default' => false)); ?>
    <?php echo $this->Form->input('ajaxSearchAll', array('type' => 'text', 'id' => 'ajaxSearchAll', 'name' => 'ajaxSearchAll', 'label' => false, 'placeholder' => 'Bitte PLZ eingeben'))?>
    <?php $before = $this->Js->get('#loading')->effect('fadeIn', array('buffer' => False)); ?>
    <?php $success = $this->Js->get('#loading')->effect('fadeOut', array('buffer' => False)); ?>
    <?php echo $this->Js->get('#ajaxSearchAll')->event('keyup', $this->Js->request(
        array('controller'=>'Posts', 'action'=>'index'),
            array(
                'update'=>'#erfolgreich_ajax',
                'before' => $before,
                'success' => $success,
                'async' => true,
                'dataExpression' => true,
                'method' => 'post',
                'data'=>$this->Js->serializeForm(array('isForm'=>'false', 'inline'=>'true'))
            )   
        )
    ); ?>
    <?php echo $this->Form->end();?>        
</div>
/// IRRELEVANT STUFF ///
<div id="loading" style="display: none;">
    <div style="float:left;margin-top: 14px"><?php echo $this->Html->image('ajax-loader.gif', array('id' => 'busy-indicator')); ?></div>
    <div style="float:left;margin: 22px 0 0 10px;color: #fff"><p>Suche nach Inseraten l&auml;uft ...</p></div>
</div>

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T13:47:49+00:00Added an answer on June 15, 2026 at 1:47 pm

    I found a solution that works fine 🙂

    That´s with saving session-parameters which are read on every page-click. Finally the hint of Daniel with the ajax-pagination-code in the view gave the ability to differentiate between a non-ajax-call and an ajax-call. So every search and pagination-link is processed in the ajax-path of the controller-code while deleting of the session-parameters can be processed outside (that was some of my main problems earlier).

    Controller Code:

       function index() {
        if(!$this->RequestHandler->isAjax()){
            $this->Session->delete('Ajax.searchA');
            $this->Session->delete('Ajax.searchS');
            $this->Session->delete('Ajax.searchB');
        }
        if($this->RequestHandler->isAjax()){
            if(!empty($this->request->data['ajaxSearchAll'])){
                $this->Session->write('Ajax.searchA', $this->request->data['ajaxSearchAll']);
                $this->Session->delete('Ajax.searchS');
                $this->Session->delete('Ajax.searchB');
                $posts = $this->paginate('Post', array('ZIPCODE LIKE' => '%' . $this->Session->read('Ajax.searchA') . '%')); 
                $this->set(compact('posts')); 
                $this->render('SearchAll', 'ajax');         
            } else{
                if($this->Session->read('Ajax.searchA') != null){
                    $posts = $this->paginate('Post', array('ZIPCODE LIKE' => '%' . $this->Session->read('Ajax.searchA') . '%')); 
                    $this->set(compact('posts'));   
                    $this->render('SearchAll', 'ajax'); 
                }
            }
        // OTHER 2 BLOCKS //
        }
    }
    

    In the view there had to be some adjustments too. First a div wrapping the whole page for the ajax-update to know what content to update (thanks Daniel for the hint). Second the echo $this->Js->writeBuffer(); at the bottom to get chained-links is vital for working properly. The view Code (search_all.ctp):

    <div id="searchAll">
    <?php if(empty($posts)){ ?>
            <p class="error">Leider keine Inserate gefunden :-(</p>
            <p>Sei der erste in Deinem PLZ-Bereich und erstelle ein Inserat:</p>
            <?php echo $this->Html->link('Inserat erstellen', array('controller' => 'Posts', 'action' => 'add')); ?>
        <?php } else { ?>
        <p class="message">Wir haben <?php echo $this->Paginator->counter('{:count}');?> Inserate gefunden :-)</p>
        <?php
        $this->Paginator->options(array(
                      'update'=>'#searchAll',
                      'evalScripts'=>true,
                      'before' => $this->Js->get('#loading')->effect('fadeIn', array('buffer' => false)),
                      'complete' => $this->Js->get('#loading')->effect('fadeOut', array('buffer' => false))
                      ));
        ?>
        <table>
            <tr>
                <th><?php echo $this->Paginator->sort('ZIPCODE', 'Postleitzahl'); ?></th>
            </tr>
            <!-- Hier iterieren wir in einer Schleife durch den $posts Array und geben die Daten des aktuellen Elements aus -->
    
            <?php foreach ($posts as $post): ?>
            <tr>
                <td><?php echo $post['Post']['ZIPCODE']; ?></td>
            </tr>
            <?php endforeach;} ?>
        </table>
        <?php 
        if(!empty($posts)){ 
            echo $this->Paginator->numbers();
        } ?>
    <?php 
    //debug($this->Paginator->params()); 
    //debug($this->request->params['paging']);
    debug($this->Session->read('Ajax.searchA'));
    echo $this->Js->writeBuffer();
    ?>
    

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm struggling a theme that I got, the theme uses query_posts() and pagination used
Struggling with the following problem. I have an attribute that defines the name of
Struggling with CSS selector. Want to select all FORM elements that are ancestors of
Struggling to work this one out; I have a (Tomcat6 'Context.xml') default document, which
Struggling to get any list function to work. I've been fine with _show and
struggling a bit to get the following to work : I'm trying to merge
Been struggling with this simple selector problem a couple of hours now and must
Struggling with the following SQL problem. Assume a three dimensional table with entries (h,t,q)
Struggling a bit today. I have the following method that returns a list of
This is a generalization of a question that I've been struggling with for a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.