Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
View partials - best way to do them?
  • Hey all, I just started playing with Fuel and I'm really digging it. I did come across a bump though... how do you implement the concept of "view partials" (to take a name from Rails)? For example, I have a chunk of code like this inside one of my views: <?php foreach($photoset as $photo): ?>
    <?php $photo_view = View::factory('articles/_photo'); ?>
    <?php $photo_view->set('photo', $photo); ?>
    <?php echo $photo_view->render(); ?>
    <?php endforeach; ?> This seems very chunky to me. The three lines inside the foreach should really just be a single line. Is there a cleaner way to do this? (And why doesn't the "code" button work? Actually, none of those buttons work for me (b, i, u, code, quote, url, email).
  • foreach($photoset['photoset']['photo'] as $photo)
    {
        echo View::factory('articles/_photo', array('photo' => $photo));
    }
    
  • Perfect! Thanks.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion