I'm using CakePHP to create a frontend UI for PowerDNS, using a MySQL backend. On the front page of the app I want to have a handful of widgets ('Quickly add a record', 'Quickly add a domain' etc.). One of the widgets I want is a paginated list of existing domains. 

The index function in DomainsController.php looks like this:

```php
public $paginate = array(
  'fields'     => array('id', 'name'),
  'limit'      => 25,
  'order'      => array( 'name' => 'asc' ),
  'conditions' => array( "NOT" => array( "name LIKE" => "%.arpa" ) )
);

public function index() {
  $domains = $this->paginate();
  if ( $this->request->is('requested')) {
    return $domains;
  } else {
    $this->set('domains', $domains);
  }
}

```

I've created an element that looks like this:

```php
<?php $domains = $this->requestAction('Domains/index'); ?>

<ol>
  <?php foreach( $domains as $domain) :?>
    <li>echo $domains['domain']['name']</li>
  <?php endforeach; ?>
</ol>

<?php echo $paginator->numbers(); ?>

```

When I visit the front page, I get an 'Undefinied variable: paginator' error. I've tried using $this->Paginator->numbers() instead but that just gives me 'Undefined property: View::$Paginator'. Adding the 'Paginator' helper to PagesController.php doesn't help either - $this->Paginator becomes available but I get 'Undefined index: pageCount'.

Is it possible to do this kind of pagination from an element on home.ctp or am I going to have to do some custom JavaScript stuff?

**EDIT**

Now I'm getting somewhere: I changed my DomainsController index function to this:

```
public function index() {
 $domains = $this->paginate();
 $paginator = $this->params;
 if ( $this->request->is('requested')) {
  return compact( 'domains', 'paginator' );
 } else {
  $this->set('domains', $domains);
 }
}

```

And added the following to the domainList.ctp element:

```
<?php 
$result = $this->requestAction('Domains/index');
$domains = $result['domains'];
$this->Paginator->request = $result['paginator'];
?>

<ol>
  <?php foreach( $domains as $domain) :?>
    <li>echo $domains['domain']['name']</li>
  <?php endforeach; ?>
</ol>

<?php echo $paginator->numbers(); ?>

```

$this->Paginator is now working properly and I can access all of its methods and properties and so on as normal. My problem now is that if I click on, say, '2', the browser navigates to /pages/home/page:2 but the domain list still shows page 1. Just need to figure out how to pass 'page:2' to the element. And AJAX-ify the whole thing so that I don't need to refresh the whole page.