Okay, here are a few examples that will help put everything together.
When you filter a search, the following events take place:
The user visits the site and CodeIgniter routes them to the
shop
controller. Theshop
controller loads theindex()
functionThe
index()
function recognizes that there is no third parameter in the URL, so it calls theget_all_products()
function ofShop_model
.The
index()
function loads theget_all_categories()
function ofShop_model
, passing the retuned result to$data['cat_query']
. This is passed to theviews/shop/display_products.php
file, which—using aforeach
loop—echoes out the categories.The user clicks on a category in the list. The URL calls the
index()
function, but this time with a third parameter.The
index()
function recognizes this third parameter and loads theget_all_products_by_category_name()
function ofShop_model
, passing it the thirduri
segment.The
get_all_products_by_category_name()
function ofShop_model...