2010-08-29 65 views
2

我想獲取當前Id的鄰居Id。 我在下面的工作,但我不能分隔[prev]從[下一個]鏈接。 控制器的功能如下所示:CakePHP find('neighbours')使用[next]和[prev]從數組

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輸出)? 蒂亞

回答

0

如果我理解正確:

<?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'];?> 
+0

感謝聶 這正是我需要和工作的權利了! – stargazer 2010-08-29 13:58:56