|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
ShamusMay Smarty Rookie
Joined: 28 Apr 2015 Posts: 18
|
Posted: Tue Jul 14, 2015 7:13 pm Post subject: Display Active SubCategories in Nav Tree |
|
|
I've got a navigation tree that displays all parent and subcategories. When on a subcategory page, I want to only display the active parent category and it's subcategories. Thank you for any help!
My current template code is as follows:
Code: |
{foreach $CategoriesList as $parent}
{$parent.category_name}
{foreach $parent.subcats as $subcat}
{$subcat.category_name}
{/foreach}
{/foreach}
|
My current function is:
Code: | // list of all categories
function getCategoriesList($include_subcats = false) {
$where = '';
if ($include_subcats == false) {
$where = ' where category_parent_id = 0 ';
}
$list =
getSqlResult(
"select * from category $where ORDER BY category_parent_id ASC", SQL_RESULT_ALL);
if ($include_subcats == false) {
foreach ($list as $key => $parent) {
$subcat =
getSqlResult(
"select * from category where category_parent_id = '{$parent['category_id']}' ORDER BY category_parent_id ASC", SQL_RESULT_ALL);
$list[$key]['subcats'] = $subcat;
}
}
return $list;
} |
|
|
Back to top |
|
ShamusMay Smarty Rookie
Joined: 28 Apr 2015 Posts: 18
|
Posted: Thu Jul 16, 2015 10:52 am Post subject: BUMP |
|
|
Is there a way to call a specific row in the array instead of displaying the entire array loop? |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|