У меня есть две модели, связанные с моделью сечения, которую эти две модели называют (галерея, статья), я хочу разбить все это на разделы / view.ctp.so У меня две проблемы
1-когда положить $идентификатор в $ paginate для получения статей по разделу $ id я получаю ошибку разбора 2 - как разделить две страницы (галерея, статья) в файле представления ..
var $paginate = array(
'Article'=>array(
'limit' => 1,
'page' => 1,
parse error here//
'conditions' => array('section_id'=>$id)
),
'Gallery'=>array(
'limit' => 3,
'page' => 1,
'conditions' => array('section_id'=>86))
)
;
function view($id = null) {
if (!$id) {
$this->Session->setFlash(__('Invalid gallery', true));
$this->redirect(array('action' => 'index'));
}
$gallery = $this->paginate('Gallery');
// find Articles at sections
$articles = $this->paginate('Article');
$section = $this->Section->findById($id);
// set the section for the view
$this->set(compact('articles','gallery','section'));
}
сечений / вид
<div class="related">
<table>
<tbody>
<h3> section is <?php echo $section ['Section']['name']; ?></h3>
<br />
<?php foreach($articles as $article): ?>
<tr>
<td><?php if($article['Article']['status']== 1){echo $article['Article']['title'];} ?></td>
<td><?php if($article['Article']['status']== 1){echo ' '.$html->link('View', '/articles/view/'.$article['Article']['id']);}?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php if($section['Section']['id']==86): ?>
<div class="related">
<table>
<tbody>
<?php foreach($gallery as $galler): ?>
<tr>
<td> <?php echo ' '.$html->link($galler['Gallery']['name'], '/galleries/view/'.$galler['Gallery']['id']);?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<p>
<?php
echo $this->Paginator->counter(array(
'format' => __('Page %page% of %pages%, showing %current% records out of %count% total, starting on record %start%, ending on %end%', true)
));
?> </p>
<div class="paging">
<?php echo $this->Paginator->prev('<< ' . __('previous', true), array(), null, array('class'=>'disabled'));?>
| <?php echo $this->Paginator->numbers();?>
|
<?php echo $this->Paginator->next(__('next', true) . ' >>', array(), null, array('class' => 'disabled'));?>
</div>
<?php endif ; ?>