Domanda

Sto cercando di ottenere dei vicini Ids della Id corrente. Quello che ho qui di seguito le opere, ma non riesco a separare la [prev] dal [successiva] collegamento. La funzione negli sguardi del controller come segue:

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

Quali uscita volontà o meno così:

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

        )

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

        )

)

Questo viene passato come 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; ?>

nella vista come un elemento:

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

Come si chiama il [prev] e link [next] separatamente (non un'uscita foreach)? Tia

È stato utile?

Soluzione

Se ho capito bene:

<?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'];?>
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top