Codeigniter View Example


/ Published in: PHP
Save to your folder(s)

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


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.