Posted By

JonnySnip3r on 09/09/12


Tagged

php view MVC codeigniter


Versions (?)

Codeigniter View Example


 / Published in: PHP
 

Just an example showing how to minimise the mixture of HTML and PHP in a view.

  1. <? foreach($products as $product): ?>
  2. <article class="product">
  3. <div class="innercontainer">
  4. <div class="post-header">
  5. <div class="entry-thumb">
  6. <img src="<?=base_url('assets/uploads/product_images/'.$product->image)?>" width="270" height="180">
  7. </div>
  8. <a class="entry-link more-link" href="<?=base_url('shop/'.$shop->url.'/product_id/'.$product->id)?>">See this Item</a>
  9. </div>
  10. <header class="entry-header">
  11. <h2><a href="<?=base_url('shop/'.$shop->id.'/product/'.$product->id)?>"><?=$product->name?></a></h2>
  12. <p><?=truncate($product->description, true)?></p>
  13. </header>
  14. <div class="entry-content">
  15. <ul class="post-meta">
  16. <li><span class="price-tag">£<?=$product->price?></span></li>
  17. <li>Category: <a href="#"><?=$product->category?></a></li>
  18. <?=(!empty($product->options))?'<li>Options: '.$product->options.'</li>':''?>
  19. </ul>
  20. </div>
  21. <footer class="entry-footer">
  22. <time class="datetime" datetime="<?=$product->date?>"><?=humanise_the_date($product->date)?></time>
  23. </footer>
  24. </div>
  25. </article>
  26. <? endforeach; ?>

Report this snippet  

You need to login to post a comment.