Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Display Active SubCategories in Nav Tree

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Smarty Development
View previous topic :: View next topic  
Author Message
ShamusMay
Smarty Rookie


Joined: 28 Apr 2015
Posts: 18

PostPosted: Tue Jul 14, 2015 7:13 pm    Post subject: Display Active SubCategories in Nav Tree Reply with quote

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
View user's profile Send private message
ShamusMay
Smarty Rookie


Joined: 28 Apr 2015
Posts: 18

PostPosted: Thu Jul 16, 2015 10:52 am    Post subject: BUMP Reply with quote

Is there a way to call a specific row in the array instead of displaying the entire array loop?
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Thu Jul 16, 2015 12:28 pm    Post subject: Reply with quote

http://php.net/manual/en/language.types.array.php
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Smarty Development All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP