3

我正在尝试获取当前 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 输出)?蒂亚

4

1 回答 1

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'];?>
于 2010-08-29T11:02:39.187 回答