worpress custom taxonomy title display also shows description - php

In my theme it gets the title of the custom taxonomy here
<div class="<?php echo $filters_id . ' '; echo $filters_width; if($layout == 'constrained_fullwidth') echo ' fullwidth-constrained '; if($span_num != 'elastic-portfolio-item' || $layout == 'constrained_fullwidth') echo 'non-fw'; ?>" data-alignment="<?php echo $filter_alignment; ?>" data-color-scheme="<?php echo strtolower($filter_color); ?>">
<div class="container">
<?php if($filter_alignment != 'center' && $filter_alignment != 'left') { ?> <span id="current-category"><?php echo __('All', NECTAR_THEME_NAME); ?></span> <?php } ?> <
<ul>
<?php if($filter_alignment != 'center' && $filter_alignment != 'left') { ?> <li id="sort-label"><?php echo (!empty($options['portfolio-sortable-text'])) ? $options['portfolio-sortable-text'] : __('Sort Portfolio',NECTAR_THEME_NAME); ?>:</li> <?php } ?>
<li><?php echo __('All', NECTAR_THEME_NAME); ?></li>
<?php wp_list_categories(array('title_li' => '', 'taxonomy' => 'project-type', 'show_option_none' => '', 'walker' => new Walker_Portfolio_Filter())); ?>
</ul>
<div class="clear"></div>
</div>
</div>
however whilst it displays the title great, if I add a description, the plugin also displays this here too
I want to make it only show the title...
I am using Salient Visual Composer plugin and showing the Projects "widget" in my page
The page in questions is http://www.jonnyrossmusic.com/acts-2/ where if you click Acoustic for example it also shows the description
I am assuming the problem lies at <?php echo __('All', NECTAR_THEME_NAME); ?>
Thanks

Related

How to select the end of a dynamically-generated array and hide part of its content?

everyone!
My website has a list of office contacts being dynamically generated via PHP (partial snippet below). As you can see, each list result/child has a name, address and, on a following div, a google maps frame.
What I'd like to achieve is to call the latest result of the array and have that one NOT TO display the google maps div.
I think I can probably call it with the "end()" command, but I'm not being able to wrap my head around the right way to proceed... Can anyone point me in the right direction, please?
Thank you!
<header id="standardheader">
<div class="wrap">
<nav class="standardsubnav">
<ul class="standardsubnav_list vanilla"><!--
<?php include_partial( 'contact/citynav', array('class' => 'standardsubnav') ); ?>
--></ul>
</nav>
<h1 class="standardpage_title"><?php echo $current->getHeadline(); ?></h1>
</div>
</header>
<div class="wrap">
<section class="">
<ul class="list4 vanilla">
<?php $contacts = $current->getChildren(); ?>
<?php foreach($contacts as $contact): $settings = $contact->getSettings(); ?>
<li class="item4">
<a name="<?php echo $settings['city']; ?>"></a>
<div class="link4">
<div class="link4_inner">
<h2 class="title4"><?php echo $settings['city']; ?></h2><!--
--><address class="address4">
<?php echo $settings['name']; ?><br />
<?php if(isset($settings['address1']) && $settings['address1'] != "") echo $settings['address1'] . '<br />'; ?>
<?php if(isset($settings['address2']) && $settings['address2'] != "") echo $settings['address2'] . '<br />'; ?>
<?php if(isset($settings['address3']) && $settings['address3'] != "") echo $settings['address3'] . '<br />'; ?>
<?php if(isset($settings['address4']) && $settings['address4'] != "") echo $settings['address4'] . '<br />'; ?>
<?php if(isset($settings['phone']) && $settings['phone'] != ""): ?>t. <?php echo $settings['phone']; ?><br /><?php endif; ?>
<?php if(isset($settings['fax']) && $settings['fax'] != ""): ?>f. <?php echo $settings['fax']; ?><br /><?php endif; ?>
<?php if(isset($settings['email']) && $settings['email'] != ""): ?>e. <?php echo $settings['email']; ?><?php endif; ?>
</address>
</div><!--
--><div class="link4_inner">
<?php
$mapurl = (!empty($settings['mapurl'])) ? $settings['mapurl'] : 'https://www.google.com/maps/#' . $settings['latitude'] . ',' . $settings['longitude'] . ',' . $settings['zoom'] . 'z'; ?>
<div class="gmap4" data-gmap="<?php echo htmlspecialchars( '{"lat":"'.$settings['latitude'].'","lng":"'.$settings['longitude'].'", "zoom":"'.$settings['zoom'].'", "mapurl":"'.$mapurl.'"}' ); ?>">
<noscript><?php echo __('Please enable javascript to see the map.'); ?></noscript>
<?php end($contacts)
Count the $contacts array. Then in the foreach loop check if the element beeing currently in the loop is equals the items in the array, if it's equal to the items, it's the last element, then exit the foreach:
$items = count($contacts );
$i = 0;
foreach($contacts as $contact) {
if(++$i === $items ) {
continue;
}
}

music widget in page template - select options

I am using the Rockit Now wordpress theme, which comes with a music player widget. When adding the widget to a sidebar, you have the followings options-
Title- (a section to type text..)
Artist for playlist- (a dropdown menu with all artist post names)
No of tracks to play- (a section to type a number..)
I am trying to display this widget in my artist page template so that it appears on each artist page with the music for that particular artist post.
I have added the following to my single-artists.php page template-
<?php the_widget( 'cs_music_player' ); ?>
This has successfully called the widget as I am now receiving the message 'No Results Found' on the page.. What I need to do is be able to select the options as above in the php.. I unfortunately can't work out how to do this..
Here is the cs_music_playlist_widget.php code-
<?php
class cs_music_player extends WP_Widget
{
function cs_music_player()
{
$widget_ops = array('classname' => 'cs_music_player', 'description' => 'Select artist to Play Your Playlist.' );
$this->WP_Widget('cs_music_player', 'ChimpS : MusicPlayList', $widget_ops);
}
function form($instance)
{
$instance = wp_parse_args( (array) $instance, array( 'title' => '' ) );
$title = $instance['title'];
$get_post_slug = isset( $instance['get_post_slug'] ) ? esc_attr( $instance['get_post_slug'] ) : '';
$numtrack = isset( $instance['numtrack'] ) ? esc_attr( $instance['numtrack'] ) : '';
?>
<p>
<label for="<?php echo $this->get_field_id('title'); ?>">
<span>Title: </span>
<input class="upcoming" id="<?php echo $this->get_field_id('title'); ?>" size="40" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" />
</label>
</p>
<br />
<p>
<label for="<?php echo $this->get_field_id('get_post_slug'); ?>">
<span>artist for Playlist:</span>
<br /><br />
<select name="<?php echo $this->get_field_name('get_post_slug'); ?>" style="width:225px;">
<?php
global $wpdb,$post;
$args = array( 'post_type' => 'artists', 'posts_per_page' => -1,'post_status'=> 'publish');
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
?>
<option <?php if($get_post_slug == $post->post_name){echo 'selected';}?> value="<?php echo $post->post_name;?>">
<?php echo substr(get_the_title(), 0, 20); if ( strlen(get_the_title()) > 20 ) echo "...";?>
</option>
<?php endwhile; ?>
</select>
</label>
</p>
<p>
<label for="<?php echo $this->get_field_id('noot'); ?>">
<span>No Of Tracks To Play: </span>
<input class="upcoming" id="<?php echo $this->get_field_id('numtrack'); ?>" size="2" name="<?php echo $this->get_field_name('numtrack'); ?>" type="text" value="<?php echo esc_attr($numtrack); ?>" />
</label>
</p>
<div class="clear"></div>
<?php
}
function update($new_instance, $old_instance)
{
$instance = $old_instance;
$instance['title'] = $new_instance['title'];
$instance['get_post_slug'] = $new_instance['get_post_slug'];
$instance['numtrack'] = $new_instance['numtrack'];
return $instance;
}
function widget($args, $instance)
{
global $cs_transwitch;
extract($args, EXTR_SKIP);
$title = empty($instance['title']) ? ' ' : apply_filters('widget_title', $instance['title']);
$get_post_slug = empty($instance['get_post_slug']) ? ' ' : apply_filters('widget_title', $instance['get_post_slug']);
echo $before_widget;
$args=array(
'name' => $get_post_slug,
'post_type' => 'artists',
'post_status' => 'publish',
'showposts' => 1,
);
$get_posts = get_posts($args);
if( $get_posts ) {
$get_post_id = $get_posts[0]->ID;
}else{
$get_post_id = '';
}
// WIDGET display CODE Start
if (!empty($title))
echo $before_title . $title . $after_title;
global $wpdb;
if($get_post_id <> ""){
$artist_buy_amazon_db ='';
$artist_buy_apple_db = '';
$artist_buy_groov_db ='';
$artist_buy_cloud_db = '';
$cs_artist = get_post_meta($get_post_id, "cs_artist", true);
if ( $cs_artist <> "" ) {
$xmlObject = new SimpleXMLElement($cs_artist);
$artist_release_date_db = $xmlObject->artist_release_date;
$artist_buy_amazon_db = $xmlObject->artist_buy_amazon;
$artist_buy_apple_db = $xmlObject->artist_buy_apple;
$artist_buy_groov_db = $xmlObject->artist_buy_groov;
$artist_buy_cloud_db = $xmlObject->artist_buy_cloud;
enqueue_alubmtrack_format_resources('widget');
?>
<script>
jQuery(document).ready(function($){
new jPlayerPlaylist({
jPlayer: "#jquery_jplayer_<?php echo $get_post_id;?>",
cssSelectorAncestor: "#jp_container_<?php echo $get_post_id;?>"
}, [
<?php
$my_counter = 0;
foreach ( $xmlObject as $track ){
if ( $track->getName() == "track" ) {
if ( $my_counter < $instance['numtrack'] ) {
$artist_track_title = $track->artist_track_title;
$artist_track_mp3_url = $track->artist_track_mp3_url;
echo '{';
echo 'title:"'.$artist_track_title.'",';
echo 'mp3:"'.$artist_track_mp3_url.'"';
echo '},';
}
$my_counter++;
}
}
?>
], {
swfPath: "<?php echo get_template_directory_uri()?>/scripts/frontend/Jplayer.swf",
supplied: "mp3",
wmode: "window"
});
});
</script>
<!-- Now Playing Start -->
<div class="nowplaying">
<?php $cs_by = __('By: %s', CSDOMAIN); ?>
<h5><?php if($get_post_id <> ''){echo get_the_title($get_post_id);}?></h5>
<p><?php printf($cs_by, get_the_author()); ?> - <?php if(isset($artist_release_date_db)){ if($cs_transwitch =='on'){ _e('Release Date',CSDOMAIN); }else{ echo __CS('release_date', 'Release Date'). ' : '.$artist_release_date_db; }}?></p>
<div id="jquery_jplayer_<?php echo $get_post_id;?>" class="jp-jplayer"></div>
<div id="jp_container_<?php echo $get_post_id;?>" class="jp-audio">
<div class="jp-type-playlist">
<div class="jp-gui jp-interface">
<ul class="jp-controls">
<li>previous</li>
<li>play</li>
<li>pause</li>
<li>next</li>
<li>stop</li>
<li>mute</li>
<li>unmute</li>
<li>max volume</li>
</ul>
<div class="jp-progress">
<div class="jp-seek-bar">
<div class="jp-play-bar"></div>
</div>
</div>
<div class="jp-volume-bar">
<div class="jp-volume-bar-value"></div>
</div>
<div class="jp-current-time"></div>
<div class="jp-duration"></div>
<ul class="jp-toggles">
<li>Shuffle</li>
<li>Shuffle off</li>
<li>Repeat All</li>
<li>Repeat off</li>
</ul>
</div>
<div class="jp-playlist">
<ul>
<li></li>
</ul>
</div>
</div>
</div>
</div>
<?php if($artist_buy_amazon_db <> '' or $artist_buy_apple_db <> '' or $artist_buy_groov_db <> '' or $artist_buy_cloud_db <> ''){?>
<!-- Buy Now Start -->
<div class="buynow">
<h5 class="white"><?php if($cs_transwitch =='on'){ _e('BUY NOW',CSDOMAIN); }else{ echo __CS('buy_now', 'BUY NOW'); } ?></h5>
<ul>
<?php if($xmlObject->artist_buy_cloud <> ""){?><li> </li><?php }?>
<?php if($xmlObject->artist_buy_amazon <> ""){?><li> </li><?php }?>
<?php if($xmlObject->artist_buy_apple <> ""){?><li> </li><?php }?>
<?php if($xmlObject->artist_buy_groov <> ""){?><li> </li><?php }?>
</ul>
<!-- Buy Now End -->
<div class="clear"></div>
</div>
<div class="clear"></div>
<?php } //Buy now Condition end?>
<?php }else{?>
<div class="list-thumb">
<ul>
<li>
<h2><?php _e("No results found.",CSDOMAIN); ?></h2>
</li>
</ul>
</div>
<?php
}
} // if artist is not Selected
else{
echo '<div class="box-small no-results-found"> <h5>';
_e("No results found.",CSDOMAIN);
echo ' </h5></div>';
}
echo $after_widget;
}
}
add_action( 'widgets_init', create_function('', 'return register_widget("cs_music_player");') );?>
the_widget accept three arguments:
$widget : the widget name, in your case cs_music_player
$instance : the widget instance settings. It's an array where your widget options goes. You can do something like this: array('title' => 'Your widget title', 'get_post_slug' => 'slug_of_your_artist', 'numtrack' => 10)
$args : an array of options used to display your widget. You can send an empty array to use the defaults, or just ignore that parameter.
In the end, your widget call will look like that:
global $post;
the_widget(
'cs_music_player',
array(
'title' => 'Your widget title',
'get_post_slug' => $post->post_name,
'numtrack' => 10
)
);

getting resized product pictures without loading product

Regarding the poor performances of my magento homepage (4 seconds computing before it start loading assets) i optimized my source code to go down to 1 second, by removing all the $_product->load that were in my loops.
But i'm facing another issue, i can't call the picture this way anoymore :
<img src="<?php echo $this->helper('catalog/image')->init($_product, 'image')->resize(135); ?>"
so, i began to call thumbnails
<?php echo Mage::getModel('catalog/product_media_config')->getMediaUrl($_product->getThumbnail()); ?>
but there's few points that annoys me, the 2nd call don't get a default placeholder picture if no picture is found, and the bigger problem is, all the magento's product have only a large res file, which is called if i don't upload a thumbnail for each product (note : i got 1600+ products, i'd like to avoid a manual upload for every single item)
So i have two options : getting th catalog/image helper to work without loading product, or finding a way to generate all the thumbnail with the high res pictures (i looked for an extension doing this, but i guess i'm a bad googler)
EDIT : here's the collection call
$selections_products = Mage::getModel('catalog/product')->getCollection()
->addAttributeToSelect(
array(
'name',
'special_from_date',
'special_to_date',
'thumbnail',
'image',
'couleur',
'special_price',
'url_path',
'price',
'format',
'selection_moment',
'selection_rouge',
'selection_blanc',
'selection_cdc',
'selection_champagne',
'selection_exception'
)
)
->addAttributeToFilter(array(array('attribute'=>'attribute_set_id', 'like' => '4')))
->addAttributeToFilter(
array(
array('attribute'=>'selection_moment', 'like' => '1'),
array('attribute'=>'selection_rouge', 'like' => '1'),
array('attribute'=>'selection_blanc', 'like' => '1'),
array('attribute'=>'selection_cdc', 'like' => '1'),
array('attribute'=>'selection_champagne', 'like' => '1'),
array('attribute'=>'selection_exception', 'like' => '1')
)
);
$selections_products->getSelect()->limit(32);
EDIT 2 : foreach on the collection :
<?php $i = 0;
foreach($selections_products_rouge as $_product): ?>
<?php if($i==0 || $i==4): ?>
<tr>
<?php endif; ?>
<td>
<div class="prod-resume">
<div class="thumb-wrapper">
<div class="thumb">
<div class="pic-holder">
<a href="<?php echo $_product->getProductUrl() ?>">
<img height="220" src="<?php echo Mage::getModel('catalog/product_media_config')->getMediaUrl($_product->getThumbnail()); ?>"/>
</a>
</div>
</div>
</div>
<h3 class="title"><?php echo $_product->getName(); ?></h3>
<div class="type">
<?php
$cats = $_product->getCategoryIds();
$j = 0;
foreach ($cats as $category_id) {
$_cat = Mage::getModel('catalog/category')->load($category_id);
if($_cat->getLevel() != 2 && $j < 2 && $_cat->getName() != 'Default Category'){
echo '<span>'.$_cat->getName().'</span>';
$j++;
}
}
$couleur = $_product->getResource()->getAttribute('couleur')->getFrontend()->getValue($_product);
$format = $_product->getResource()->getAttribute('format')->getFrontend()->getValue($_product);
echo '<span>'.$couleur.'</span>';
echo '<span>'.$format.'</span>';
?>
</div>
<?php echo get_promo_stamp($_product); ?>
<div class="bottom">
<?php echo get_product_price_html($_product,$_taxHelper,$_coreHelper); ?>
<div class="btns">
Fiche produit
<?php if($_product->isSaleable()): ?>
Ajouter au panier
<?php endif; ?>
</div>
</div>
Aperçu
</div>
</td>
<?php if($i==3 || $i==7): ?>
</tr>
<?php endif; ?>
<?php $i++;endforeach; ?>

Adding else line when a category is empty

I'm working on a wordpress website using this search facility:
http://spruce.it/noise/two-category-dropdown-search-filter-in-wordpress/
All is working OK but in the last few lines I want to include a line to say that if there are no posts in the two categories, e.g. dentists in brighton to show a 'there are no posts' kind of message. My php is very limited and what I've tried doesn't work. I was hoping to add it in before the else statement but this may not be correct. Any pointers much appreciated!
<?php else:
if ($_GET['category'] != -1){
header('Location:'.get_category_link($_GET['category']));
} elseif ($_GET['city'] != -1){
header('Location:'.get_category_link($_GET['city']));
} else{
header('Location: http://www.test.com');
}
endif;?>
ADDITIONAL EDIT: here is the whole page content 14/01/14:
<?php
require_once('../../../wp-blog-header.php');
if (($_GET['category'] != -1) && ($_GET['city'] != -1)):
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts(
array(
'orderby' => 'date',
'order' => 'DESC',
'paged' => $paged,
'posts_per_page' => 6,
'category__and' => array(
$_GET['city'],
$_GET['category']
),
)
);
?>
<?php get_header(); ?>
<div id="main">
<div id="content" class="wide">
<?php if (have_posts()) : ?>
<h1><?php echo get_cat_name($_GET['category']) ?>,
<?php echo get_cat_name($_GET['city']) ?></h1>
<?php remove_filter ('the_content1', 'wpautop'); ?>
<h2>These <?php echo get_cat_name($_GET['category']) ?> can help you. They service businesses in <?php echo get_cat_name($_GET['city']) ?><?php if( is_category('exeter') ) echo get_page_content(585);
elseif( is_category('birmingham') ) echo get_page_content(587);
elseif( is_category('') ) echo '.';?>
</h2>
<ul id="search1"><?php while (have_posts()) : the_post(); ? >
<a href="http://www.<?php echo get_post_meta($post->ID, 'URL', true); ?>" title="Go to the URL: www.<?php echo get_post_meta($post->ID, 'URL', true); ?>" target="_blank">
<li id="<?php echo get_post_meta($post->ID, 'AdSize', true); ?>"><h5><?php the_title(); ?></h5>
<?php the_post_thumbnail( $size, $attr ); ?>
<div class="doubler"><?php the_content(''); ?>
<p>Tel: <?php echo get_post_meta($post->ID, 'Telephone', true); ?><br />Website: www.<?php echo get_post_meta($post->ID, 'URL', true); ?></p></div>
</li>
</a>
<?php endwhile; ?></ul>
<?php endif; ?>
<div class="localhelp">
<h1>Find Local Help</h1>
<form method="get" id="sponsorsearchform" action="<?php bloginfo('template_url');? >/findsponsor.php" >
<?php wp_dropdown_categories('show_option_none=Select a Category&hide_empty=1&child_of=14&orderby=name&name=category'); ?>
<?php wp_dropdown_categories('show_option_none=Select a Location&hide_empty=1&child_of=13&orderby=name&name=city'); ?>
<input type="submit" value="Search"/>
</form>
</div>
<hr />
<?php comments_template(); ?>
</div><!--end content-->
</div><!--end main-->
<?php get_footer(); ?>
<?php else:
if ($_GET['category'] != -1){
$currentCat = get_category($_GET['category']);
if ($currentCat->category_count > 0) {
header('Location:'.get_category_link($_GET['category']));
} else {
echo "No result found!";
}
} elseif ($_GET['city'] != -1){
$currentCity = get_category($_GET['city']);
if ($currentCity->category_count > 0) {
header('Location:'.get_category_link($_GET['city']));
} else {
echo "No result found!";
}
} else{
header('Location: http://www.test.com');
}
endif;?>
when there are no posts in either category the findsponsor.php is shown (i.e. the page typed above) .. I want it to say no posts found but it doesn't seem to pick up the echo "No result found!", it's just the page but with no results on.
You can get post count by using category_count attribute through get_category like;
<?php else:
if ($_GET['category'] != -1){
$currentCat = get_category($_GET['category']);
if ($currentCat->category_count > 0) {
header('Location:'.get_category_link($_GET['category']));
} else {
echo "No result found!";
}
} elseif ($_GET['city'] != -1){
$currentCity = get_category($_GET['city']);
if ($currentCity->category_count > 0) {
header('Location:'.get_category_link($_GET['city']));
} else {
echo "No result found!";
}
} else{
header('Location: http://www.test.com');
}
endif;?>
Your code only checks if a category or city ID is found. It does not check if there are any posts in one of those categories. You'd need to add some more code to check for that (count posts in that particular category).
Or if it is enough for you to test if a 'valid' category/city id is found, just alter the line in the else statement (redirect to home) and redirect it to a 'no posts found'-page, or echo a message there, something like that.
What is the best choice actually depends on where and when that code is executed. A little bit more explanation of the request flow is needed here.

Get Magento Categories with Especific Sort of Admin Panel

I wrote the code below to put together a customized menu of categories. Everything works fine, but would like the order of the categories were the same order as defined in the administrator panel where there drap and drop functionality.
<?php
$subCats = Mage::getModel('catalog/category')->load(76)->getChildren();
$dispositosCatIds = explode(',',$subCats);
?>
<ul class="menu">
<?php $controleNum = 0; ?>
<?php foreach($dispositosCatIds as $dispositoCatId): ?>
<?php $aparelhoCat = Mage::getModel('catalog/category')->load($dispositoCatId); ?>
<?php if($aparelhoCat->getIsActive()): ?>
<li class="<?php print $controleNum ? '' : 'submenu first'; ?>"><a class="drop" href="<?php echo $aparelhoCat->getUrl(); ?>"> <span><?php echo $aparelhoCat->getName(); ?></span></a> <!--Begin 6 column Item -->
<div class="dropdown_6columns">
<div class="inner"><span class="title"><?php echo $aparelhoCat->getName(); ?></span>
<div class="col_2">
<div class="col_2 firstcolumn"><img src="<?php echo $aparelhoCat->getImageUrl(); ?>" alt="<?php echo $aparelhoCat->getName(); ?>" /></div>
</div>
<div class="col_4" style="margin-bottom: 20px;">
<?php echo $aparelhoCat->getDescription(); ?>
</div>
<div class="col_2 categorias-super"><span class="title_col">Produtos para <?php echo $aparelhoCat->getName(); ?></span>
<?php $subSubCats = $aparelhoCat->getChildrenCategories();?>
<?php if (count($subSubCats) > 0): ?>
<?php //$controleNumLI = 0; ?>
<ul style="list-style: none; float: none !important;">
<?php foreach($subSubCats as $_subcategory): //Rodando entre as categorias de Um dispositivo ?>
<?php if($_subcategory->getIsActive()): ?>
<li class="level1 <?php //print $controleNumLI ? '' : 'first'; ?>"> <?php echo $_subcategory->getName(); ?></li>
<?php //$controleNumLI += 1; ?>
<?php endif; ?>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</div>
</div>
</div>
</li>
<?php $controleNum += 1; ?>
<?php endif; ?>
<?php endforeach; ?>
</ul>
I tried to use other modes (based here) can do this, but I could not. The problem that the function returns getChildren() is a string with IDs in ascending order.
Some Ideas?
This is the code I use to display category in a dropdown box in the order of the admin... the key is setOrder('path','ASC')
$categories = array();
$_categories = Mage::getModel('catalog/category')->getCollection()
->addAttributeToFilter('is_active',array('eq'=>true))
->addAttributeToSelect('level')
->setOrder('path','ASC')
->addAttributeToSelect('name')->load();
foreach($_categories as $cat){
$level = $cat->getLevel() - 1;
$pad = str_repeat("----", ($level > 0) ? $level : 0);
$categories[] = array('value' => $cat->getEntityId(), 'label' => $pad . ' ' . $cat->getName());
}
print_r($categories);
You could do something like this: create array tree from array list
I got it:
$dispositovosCategoryId = 76;
$dispositovosCategoryIds = Mage::getModel('catalog/category')->getCollection()
->addFieldToFilter('parent_id', array('eq'=>$dispositovosCategoryId))
->addAttributeToFilter('is_active',array('eq'=>true))
->addAttributeToSelect('level')
->setOrder('position','ASC')
->addAttributeToSelect('name','url','image')
->load();

Categories