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

le="color: #000000"><?php $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
le="color: #000000"><?php 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

Donat-O-Meter

Stats
Goal: $15.00
Due Date: Jul 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $15.00
Make donations with PayPal!

Latest GitHub Commits