我正在尝试获取当前Id的邻居ID。 我下面的内容有效,但我无法将[prev]与[next]链接分开。 控制器中的功能如下所示:
function prevNext() {
return $this->System->find('neighbors', array('fields' => 'name', 'value' => 3));
}
将输出如下内容:
Array
(
[prev] => Array
(
[System] => Array
(
[name] => Aegerter
[id] => 4004
)
)
[next] => Array
(
[System] => Array
(
[name] => Canonica
[id] => 4006
)
)
)
这将作为requestAction传递 -
<?php $systems = $this->requestAction('systems/prevNext'); ?>
<?php foreach($systems as $system): ?>
<?php echo $html->link($system['System']['id'],array('action'=>'view', $system['System']['id']));?>, <?php echo $system['System']['name'];?>
<?php endforeach; ?>
作为元素进入视图:
<?php echo $this->element('systems'); ?>
如何单独调用[prev]和[next]链接(不是foreach输出)? TIA
答案 0 :(得分:1)
如果我理解正确:
<?php echo $html->link($systems['prev']['System']['id'],array('action'=>'view', $systems['prev']['System']['id']));?>, <?php echo $systems['next']['System']['name'];?>
<?php echo $html->link($systems['next']['System']['id'],array('action'=>'view', $systems['next']['System']['id']));?>, <?php echo $systems['next']['System']['name'];?>