34 Ansichten
Passing a variable from the controller into the view
creativewild

17 Fach, 53 Antworten

Mitwirkende Geber
Ungelesene Nachricht
This is part of the controller (index.php)

arsort($match_sort);

$this ->css('gw2wvw');

$params = array(
'title' => 'GW2 World Vs World',
'content' => $this->load->view('index', array('match_sort' => $match_sort))
);
return new Panel($params);


This is the View(index.tpl.php)


<div class="gw2-wvw-matchups">
<ul class="gw2-matchups">
<?php foreach ($match_sort as $match_detail) {?>
<li class="match <?php echo $match_detail['world_color']; ?>">
<span class="world <?php echo $match_detail['world_home']; ?>"><?php echo $match_detail['world_name']; ?></span>
<span class="points"><?php echo number_format($match_detail['world_score']); ?></span>
</li>
<?php }?></ul>



I have the variable $match_sort loaded into the Panel function to be passed into the view but it still does not work.

This is a screenshot of the Original widget using only php interlaced with html in the heroislusitanos.com website:





EDIT: Added the view information, and screenshot of the original widget
2 Teilnehmer
3 Antworten
eResnova

17 Fach, 875 Antworten

Mitwirkende
Ungelesene Nachricht
U can call your variable like this :

<?php foreach ($data['match_sort '] as $match_detail): ?>
<li class="list-group-item">
<?php echo ... ; ?>
</li>
<?php endforeach; ?>
creativewild

17 Fach, 53 Antworten

Mitwirkende Geber
Ungelesene Nachricht
Awesome... it works :D

Many thanks Jérémy, you are a life saver.
eResnova

17 Fach, 875 Antworten

Mitwirkende
Ungelesene Nachricht
No problem Luis !
U can check ./neofrag/widgets/members for more examples ;)