Hi,
I'm having a problem with pagination from an external controller.
So I have a view in PagesController that should get paginated content
from NewsController, and this works. I get paginated content, but when
I do $this->Paginate->numbers();
I need numbers to show, because I need to automate them to turn over
each page every six seconds.
Even that the view puts every $news in a separately marked layer would
do, as I could then select it via jQuery and paginate with it.
Or is it something simple as not using PagesController, i'm only using
it because content is basically static, with only a few db fetches.
And if so, it wouldn't work for getting data anyway, or would it.
Please, can anybody help?
Thanks in advance :)
Code below :)
class NewsController extends AppController {
public $helpers = array('Html', 'Session','Js' =>
array('Jquery'),'Paginator');
var $paginate = array(
'limit' => 1,
'pages'=>3,
'order' => array(
'News.create_date' => 'desc'
)
);
public function index() {
$this->layout='admin';
$this->News->recursive = 1;
$news = $this->paginate();
if ($this->request->is('requested')) {
return $news;
} else {
$this->set('news', $news);
}
}
=======
/View/Pages/home.ctp
<div class="six columns">
<div class="content-box">
<h1>Novosti</h1>
<div class="content">
<a href=""><img src="img/content-box-img.png" width="140"
height="199"></a>
<?php $news =$this ->
requestAction('news/index/paginate:create_date/
desc:limit/1');?>
<?php foreach ($news as $news):?>
<p><?php echo $news['News']['body'];?></p>
<p>
<a class="more" href="">Pročitaj više...</a>
</p>
<?php endforeach;?>
<?php $this->Paginate->numbers();?>
</div>
</div>
=========
<?php
App::uses('AppController', 'Controller');
class PagesController extends AppController {
public $name = 'Pages';
public $helpers = array('Html', 'Session','Js' =>
array('Jquery'),'Paginator');
var $paginate = array('limit' => 3, 'page' => 1);
public $uses = array('News','Blocks');
public function display() {
$path = func_get_args();
$count = count($path);
if (!$count) {
$this->redirect('/');
}
$page = $subpage = $title_for_layout = null;
if (!empty($path[0])) {
$page = $path[0];
}
if (!empty($path[1])) {
$subpage = $path[1];
}
if (!empty($path[$count - 1])) {
$title_for_layout = Inflector::humanize($path[$count -
1]);
}
$this->set(compact('page', 'subpage', 'title_for_layout'));
$this->render(implode('/', $path));
}
}
--
Our newest site for the community: CakePHP Video Tutorials
http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others
with their CakePHP related questions.
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php