views:

9

answers:

1

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

A: 

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'];?>
Nik
Thanks NikThis is exactly what I needed and works right away!
stargazer