вопрос
Помогите вывести категории с определенного id т.е (по умолчание идет вывод вида 1,2,3,4,5,6), а нужно 5,6,7,8,9
<?php
if( ! defined( 'DATALIFEENGINE' ) ) {
die( "Hacking attempt!" );
}
$template = !empty($template) ? $template.'.tpl' : 'viewsetcategories.tpl';
$showcat = !empty($showcat) ? explode( ',',$showcat ) : array();
$my_cat = array();
if(count($showcat)>0){
foreach($showcat as $value)if (isset($cat_info[$value])) $my_cat[$value] = $cat_info[$value];
}else{
$my_cat = $cat_info;
}
/* echo'<pre>';print_r($cat_info);echo'</pre>'; */
if (!function_exists('treeCategorySort')) {
function treeCategorySort(array $elements, $parentId = 0) {
$branch = array();
if( count( $elements ) ) {
foreach ($elements as $element) {
if(!isset($elements[$element['parentid']]) && $element['parentid']!=0) $element['parentid'] = 0;//$elements[$element['id']]['parentid']=0;
if ($element['parentid'] == $parentId) {
$children = treeCategorySort($elements, $element['id']);
if ($children) {$element['children'] = $children;}
$branch[] = $element;
}
}
return $branch;
}
}
}
if (!function_exists('create_info_cat')) {
function create_info_cat(array $node,$nbsp=0,$template=''){
global $tpl,$config;
if( !$ComTpl ){
$tpl->load_template($template);
$ComTpl = $tpl->copy_template;
}else{$tpl->copy_template = $ComTpl;}
$id = md5( microtime().uniqid( mt_rand(), TRUE ) );
if ( preg_match( "#\\{level=['\"](.+?)['\"]\\}#i", $tpl->copy_template, $matches ) && $nbsp>1) {
$level = '';
for($j = 1; $j <= $nbsp; $j ++) {$level .= $matches[1];}
$tpl->set( $matches[0], $level );
}else{
$tpl->copy_template = preg_replace( "#\\{level=['\"](.+?)['\"]\\}#is", "", $tpl->copy_template );
}
$tpl->set( "{level}",$nbsp);
$tpl->set( "{id}",$node['id']);
$tpl->set( "{name}",stripslashes($node['name']));
$tpl->set( "{alt_name}",$node['alt_name']);
$tpl->set( "{cat-url}",$config['http_home_url'].get_url( $node['id'] ).'/');
$tpl->set( "{descr}",stripslashes($node['descr']));
if( $node['icon'] ) {
$tpl->set( '{icon}',$node['icon'] );
} else {
$tpl->set( '{icon}', "{THEME}/dleimages/no_icon.gif" );
}
$tpl->compile( "views_cat_".$id);
$tpl->clear ();
return $tpl->result['views_cat_'.$id];
}
}
if (!function_exists('display_treeCategorySort')) {
function display_treeCategorySort($tree,$template='',$nbsp2 = 0) {
$content = '';
if(!is_null($tree) && count($tree) > 0) {
$nbsp2 += 1;
foreach($tree as $key => $node) {
$content .= create_info_cat($tree[$key],$nbsp2,$template);
if(!empty($node['children']))$content .= display_treeCategorySort($node['children'],$template,$nbsp2);
}
return $content;
}}}
$massivCat = treeCategorySort($my_cat);
$cont = display_treeCategorySort($massivCat,$template);
echo $cont;
?>