What I am trying to achieve is to have one route for all of the site categories with the following URL structure:
mysite.org/FirstCategory
mysite.org/SecondCategory
mysite.org/ThirdCategory
In addition, I will also have dynamic subcategories with the followoing URL structure:
mysite.org/MainCategory/Subcategory-1
mysite.org/MainCategorySubcategory-2
mysite.org/SecondCategory/Subcategory-1
mysite.org/SecondCategory/Subcategory-2
My question is how should I setup my controller and route? After familiarizing myself with FatFree documentation, more or less, I still cannot find the answer to this question.
Any suggestions or any reading materials can help a lot.
Assuming you have a landing page at mysite.org, you are most likely going to have a route that serves it similar to below;
GET /=MainController->render
You can then have menu items on that landing page that call up the different site categories and subcategories. A sample menu item can look like below;
`<li><a href="{{ @BASE . '/main/cat2/subcat0'}}"><i class=""></i> SecondCategory</a></li>`
`<li><a href="{{ @BASE . '/main/cat2/subcat1'}}"><i class=""></i> Subcategory-1</a></li>`
You can then have a dynamic route to handle these links
GET /main/cat@cat_id/subcat@subcat_id=MainController->displaylink
You can then pick up these as params in your controller and return the required content
$cat_id = $f3->get('PARAMS.cat_id')
$subcat_id = $f3->get('PARAMS.subcat_id')