bradgrafelman;10979518 wrote:Well, you could use [man]var_dump/man to get detailed information about the value being returned... but whether it's NULL or an empty string or an empty object or... it doesn't really mater; the point is the data you're after obviously wasn't there.
It would appear you are correct, yes.
Wow, does that mean it's hopeless? I have seriously been trying to do this for over 10 hours :o
I have found this little piece here that pulls out all children whereas I only want to have the first level children categories...the getUrl() in there seems to work just fine?
<?php
$category = Mage::getModel('catalog/category')->load(3); // 7 is the ID of Main Category
$subcategory = $category->getAllChildren(true);
array_shift($subcategory);
if($subcategory!=null)
{
foreach ($subcategory as $sub)
{
$sub1 = Mage::getModel('catalog/category')->load( $sub);?>
<li><a href="<?php echo $sub1->getUrl();?>"><span>
<?php echo $sub1->getName();
}?>
<?php }?>
Do you know what's the difference between this code and mine? I have revised the code I started out last night in my original post (before resorting to your suggested echo method) and figured out how to do it without creating a parsing error:
<?php
$children = Mage::getModel('catalog/category')->getCategories(3);
foreach ($children as $category)
{
?>
<li><a href="<?php echo $category->getUrl()?>">
<span><?php echo $category->getName()?></span></a></li>
<?php
}
?>
However, in this piece of code the getUrl() also doesn't work.....:quiet: I wonder what it is about the above code that pulls out all children categories that makes the getUrl() function correctly????