start code snippet: (the idea is that build_subtree_toc keeps a path as well as a tree, the smarty can use a counter to keep track of depth as it recursively calls itself and thus check the current page against the path at the correct depth)
function build_subtree_toc($id,$currentPageId,$slide=false,$order='asc',$tocPrefix='',$depth=0) {
$cant = $this->getOne("select count(*) from `tiki_structures` where `parent_id`=?",arrayint)$id;
if ($cant) {
if ($id == $currentPageId) {
$path = array($id);
} else {
$path = false;
}
$query = "select `page_ref_id`, `pageName`, `page_alias`, tp.`description` from `tiki_structures` ts, `tiki_pages` tp ";
$query.= "where ts.`page_id`=tp.`page_id` and `parent_id`=? order by ".$this->convert_sortmode("pos_".$order);
$result = $this->query($query,arrayint)$id;
$prefix=1;
while ($res = $result->fetchRow()) {
$res'prefix'=($tocPrefix==)?:"$tocPrefix.";
$res'prefix'.=$prefix;
$prefix++;
if ($res'page_ref_id' != $id) {
$sub = $this->build_subtree_toc($res'page_ref_id',$slide,$order,$res'prefix',$currentPageId);
if (is_array($sub'tree')) {
$res'sub' = $sub'tree';
if ($sub'path') {
$path = array_merge($id,$sub('path'));
}
}
}
if ($res%22page_alias%22<>"") $res%22pageName%22=$res%22page_alias%22;
$back[] = $res;
}
} else {
return array('tree'=>false, 'path'=>false);
}
return array('tree'=>$back,'path'=>$path);
}
function get_toc($page_ref_id,$currentPageId,$order='asc',$showdesc=false,$numbering=true,$numberPrefix='',$type='plain',$maxdepth=0) {
$structure_tree_holder = $this->build_subtree_toc($page_ref_id,$currentPageId,false,$order,$numberPrefix);
$smarty->assign('struct_type',$type);
$smarty->assign('struct_tree',$structure_tree_holder'tree');
$smarty->assign('path_to_current',$structure_tree_holder'path');
$smarty->assign('struct_showdesc',$showdesc);
$smarty->assign('struct_numbering',$numbering);
$smarty->assign('struct_prefix',$numberPrefix);
$smarty->assign('struct_curdepth',0);
return $smarty->fetch("structures_toc-level.tpl");
//return $this->fetch_toc($structure_tree,$showdesc,$numbering,$type,$asmenu,$detailstyle,$maxdepth);
}
To help developers solve the bug, we kindly request that you demonstrate your bug on a show2.tiki.org instance. To start, simply select a version and click on "Create show2.tiki.org instance". Once the instance is ready (in a minute or two), as indicated in the status window below, you can then access that instance, login (the initial admin username/password is "admin") and configure the Tiki to demonstrate your bug. Priority will be given to bugs that have been demonstrated on show2.tiki.org.
filename | created | hits | comment | version | filetype | ||
---|---|---|---|---|---|---|---|
No attachments for this item |