문제

I am trying to get the neighbors Ids of the current Id. What I have below works, but I cannot separate the [prev] from the [next] link. The function in the controller looks as follows:

function prevNext() {
    return $this->System->find('neighbors', array('fields' => 'name', 'value' => 3));
 }

Which will output something like this:

Array
(
    [prev] => Array
        (
            [System] => Array
                (
                    [name] => Aegerter
                    [id] => 4004
                )

        )

    [next] => Array
        (
            [System] => Array
                (
                    [name] => Canonica
                    [id] => 4006
                )

        )

)

This gets passed as a 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; ?>

into the view as an element:

<?php echo $this->element('systems'); ?>

How do you call the [prev] and [next] link separately (not a foreach output)? Tia

도움이 되었습니까?

해결책

If i understand correctly:

<?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'];?>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top