Skip to content

Instantly share code, notes, and snippets.

@sajadtorkamani
Created April 17, 2015 19:36
Show Gist options
  • Save sajadtorkamani/cf5615e43af3c1a64550 to your computer and use it in GitHub Desktop.
Save sajadtorkamani/cf5615e43af3c1a64550 to your computer and use it in GitHub Desktop.
// CONTROLLER: Stores retrieved product fields into a F3 array variable 'products';
public function index()
{
$this->f3->set('products', $this->db->exec("SELECT * FROM products LIMIT 5"));
$this->f3->set("page_title", "Homepage");
$this->f3->set("page_id", "home");
$this->f3->set('view','app/views/user/home.htm');
}
// VIEW: Traverses through the F3 array variable 'products' and displays its fields in the view template.
<ul>
<repeat group="{{ @products }}" value="{{ @product }}">
<li>
<a href="{{ @BASE }}/product/{{ @product.productID }}/{{ @product.name }}" class="product-thumbnail">
<img src="{{ @IMAGEPATH }}{{ @product.thumb_image }}" alt="{{ @product.name }}">
<button class="view" title="View image">
<a href="{{ @IMAGEPATH }}{{ @product.full_image }}">Hover</a>
</button>
</a>
<a href="{{ @BASE }}/product/{{ @product.productID }}/{{ @product.name }}" class="product-name">{{ @product.name }}</a>
<span class="product-price">£{{ @product.price }}</span>
<span class="product-price"></span>
</li>
</repeat>
</ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment