• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Looped view keeps variables

#1
[eluser]Unknown[/eluser]
Hello,

first thing: I'm using HMVC, so that may be interfering.

I request $news for a newsarray and want to loop every entry in a singleview to get the rendered the newslist. There is an optional subarray called medias, which is just created and filled when medias are there. In my case, just the first entry has a media entry, all others do not. If I output the complete list, every news has the same medias assosiated. I'm using the following code:

Code:
$list = '';
if($news !== false){
    foreach($news as $entry){
        // get medias
        $mediaArray = $this->Model_news->get_media($entry['id']);
        
        if($mediaArray !== false && count($mediaArray) > 0){
            $entry['medias'] = array();
            foreach($mediaArray as $media){
                $entry['medias'][] = $media;
            }
        }
        var_dump($entry);
        $list .= $this->load->view('singleentry',$entry,true);
    }
}

The check what exactly is passed to the view, I dump the entry which is correctly containing the media in just the first loop, never in any of the later. Still the view thinks it has the $medias variable available and outputs the medias in every other entry. I also tried to unset the variable in the view itself, but that doesn't help.

Anyone has an idea what can cause this and how to solve this?


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.