1
Mazar
how can i properly print this array in smarty template. it is gone complecated
  • 2009/12/21 8:27

  • Mazar

  • Not too shy to talk

  • Posts: 191

  • Since: 2009/1/4 0


Having problem assigning a multidimensional array to template

my function

$catid = (isset($_GET['subcat'])) ? intval($_GET['subcat']) : 0;
$subcats_show showSubcats($catid);
print_r($subcats_show);
$xoopsTpl->assign('subs'$subcats_show);


function 
showSubcats($catid)
{
    global 
$xoopsUser$xoopsConfig$xoopsDB$xoopsModuleConfig;
    
$subs = array();
    

    
//print $sql."n";
    
    
$query $xoopsDB->query(' SELECT * FROM ' $xoopsDB->prefix('destinations_topic'). " WHERE topic_pid=".$catid." ");
    
$i =0;
    while (
$row $xoopsDB->fetchArray($query)) 
    {
        
$subs[$i]['parent']['topic_id'] = $row['topic_id'];
        
$subs[$i]['parent']['topic_title'] = $row['topic_title'];
        
//$categories[$i]['topic_img'] = $row['topic_img'];
        
$child $row['topic_id'];
         
    
//print_r($child_array);
            
$topicHandler =& xoops_getModuleHandler('destinations_topic''destinations');
            
$criteria = new Criteria('topic_pid',$child);
            
$arr $topicHandler->getAll($criteria);
            
$mytree = new XoopsObjectTree($arr'topic_id''topic_pid');
            
$child_array $mytree->getAllChild($child);
            
            foreach (
$child_array as $child)
            {
              
                
$subs[$i]['child']['topic_id'] = $child->getVar('topic_id');
                
$subs[$i]['child']['topic_title'] = $child->getVar('topic_title');
                
//$subs['parent'][$i]['child'][$j]['url'] = $url.$child->getVar($id_name);
               
            
}
       
        
$i++;
    }
    return 
$subs;
}


in print recursive i am getting the array like this
Array
(
    [
0] => Array
        (
            [
parent] => Array
                (
                    [
topic_id] => 2
                    
[topic_title] => Dubai
                
)

            [
child] => Array
                (
                    [
topic_id] => 3
                    
[topic_title] => Dubai Speicals
                
)

        )

    [
1] => Array
        (
            [
parent] => Array
                (
                    [
topic_id] => 4
                    
[topic_title] => Abu Dhabi
                
)

            [
child] => Array
                (
                    [
topic_id] => 5
                    
[topic_title] => Abu Dubai Specials
                
)

        )

)

this is the pre recursive

how can i print this array properly in smarty template?

2
Mazar
Re: how can i properly print this array in smarty template. it is gone complecated
  • 2009/12/21 9:53

  • Mazar

  • Not too shy to talk

  • Posts: 191

  • Since: 2009/1/4 0


Thanks solved it


Login

Who's Online

267 user(s) are online (141 user(s) are browsing Support Forums)


Members: 0


Guests: 267


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits