【问题标题】:CakePHP find('neighbors') use [next] and [prev] from arrayCakePHP find('neighbors') 使用数组中的 [next] 和 [prev]
【发布时间】:2010-08-29 07:30:45
【问题描述】:

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

【问题讨论】:

    标签: cakephp neighbours


    【解决方案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'];?>
    

    【讨论】:

    • 谢谢 Nik 这正是我所需要的并且可以立即使用!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-10-26
    • 1970-01-01
    • 1970-01-01
    • 2011-09-19
    • 1970-01-01
    • 2023-01-05
    • 1970-01-01
    相关资源
    最近更新 更多