Register Advertise with usHelp Desk Today's Posts Search

Closed Thread
Thread Tools Search this Thread
Unread 4th Dec 2010, 07:10 AM   #1
Happy Days
War Room Member
 
Aj Wilson's Avatar
 
Join Date: 2007
Location: Melbourne, Australia.
Posts: 408
Thanks: 58
Thanked 105 Times in 66 Posts
Default
PHP or Magento Experts ... Please Help?
Share on: 
fb share twitter share gplus share more share

Hey guys,

Basically I've got a vertical nav menu in a magento ecommerce site.

The code below is displaying the vertical nav menu the sub-categories
on the home page, but they're not hyperlinked (yet).

PHP Code:
<?php
 
= Mage::getModel('catalog/category')->load(2)->getChildren();
 = 
explode(',',);
?>
<ul>
<?php foreach( as ): ?>
<li>
<?php
 
= Mage::getModel('catalog/category')->load();
echo ();
 = 
Mage::getModel('catalog/category')->load(())->getChildren();
 = 
explode(',',);
?>
<?php 
if(count() > 1):?>
<ul>
<?php foreach( as ) :?>
<li>
<?php
 
= Mage::getModel('catalog/category')->load();
echo ();
?>
</li>
<?php endforeach;?>
</ul>
<?php endif; ?>
</li>
<?php endforeach; ?>
</ul>
Apparently Im suppose to add this code somewhere so
it'll hyperlink the categories.

Here's the "instructions" that were given...

NOTE:
After loading each category you have a whole array of different attributes you can use. If you wanted to make each category listing be a link, simply use the getUrl() function in a similar fashion:
Here's the code...



Code:
 
 
#a href="<?php echo ()?>">    <?php echo ()?></a#

OK, seems as though the Warrior Forum wont allow me
to show you the code...

So if you could kindly check this site out,
all the code is there.

Magento Custom Category Listing Block | Devin R. Olsen Web Developer

There's a youtuibe video there as well, but
mentions nothing of the hyperlinking code.


Now, Im not sure if this is enough info, but Im pretty sure
a php expert could easily pick this up and whip their magic to give some much needed advice?

Any assistance would be greatly appreciated,
Thanks a bunch in advance,

- aj

Aj Wilson is offline  
Unread 4th Dec 2010, 12:55 PM   #2
Article Publisher
War Room Member
 
Havenhood's Avatar
 
Join Date: 2009
Location: Out West!
Posts: 140
Thanks: 9
Thanked 18 Times in 18 Posts
Default
Re: PHP or Magento Experts ... Please Help?
Share on: 
fb share twitter share gplus share more share

I don't use Magento, but I believe you're looking for something like this:

Now, for every occurrence of echo $category->getName(); use the code below:



?>

<a href="<?php echo $category->getUrl()?>">

<?php echo $category->getName()?>
</a>

<?php



For every occurrence of echo $subCategory->getName(); use this code:


?>

<a href="<?php echo $subCategory->getUrl()?>">

<?php echo $subCategory->getName()?>
</a>

<?php



Note:

The author uses only the echo $category->getName(); to reference both the top and sub categories. That may be an oversight. Give that a try.

--= -Spazzle- =--
Havenhood is offline  
The Following User Says Thank You to Havenhood For This Useful Post:
Unread 4th Dec 2010, 04:38 PM   #3
Happy Days
War Room Member
 
Aj Wilson's Avatar
 
Join Date: 2007
Location: Melbourne, Australia.
Posts: 408
Thanks: 58
Thanked 105 Times in 66 Posts
Default
Re: PHP or Magento Experts ... Please Help?
Share on: 
fb share twitter share gplus share more share

Ray,

You're a legend!

Your solutions works ... but now magento is spitting out
errors when clicking on the hyperlinks.

Just wondering if this is the correct method?

PHP Code:
<?php
 
= Mage::getModel('catalog/category')->load(2)->getChildren();
 = 
explode(',',);
?>
<ul>
<?php foreach( as ): ?>
 <li>
     <?php
    
= Mage::getModel('catalog/category')->load();
   
?>
<a href="<?php echo ()?>"> 
<?php echo ()?>
</a>
<?php 
    
= Mage::getModel('catalog/category')->load(())->getChildren();
    = 
explode(',',);
  
?>
            <?php if(count() > 1):?>
                <ul>
                <?php foreach( as ) :?>
                    <li>
                    <?php
                         
= Mage::getModel('catalog/category')->load();
                        
?>
<a href="<?php echo ()?>"> 
<?php echo ()?>
</a>
<?php
                    ?>
                    </li>
                <?php endforeach;?>
                </ul>
            <?php endif; ?>
    </li>
<?php endforeach; ?>
</ul>

or have I inserted them wrong?

Thank you so much for your help mate,

Aj Wilson is offline  
Unread 4th Dec 2010, 08:42 PM   #4
Happy Days
War Room Member
 
Aj Wilson's Avatar
 
Join Date: 2007
Location: Melbourne, Australia.
Posts: 408
Thanks: 58
Thanked 105 Times in 66 Posts
Default
Re: PHP or Magento Experts ... Please Help?
Share on: 
fb share twitter share gplus share more share

Disregard Ray ....

It was a magento issue.

Thanks again for your assistance mate.
Legend.

- aj

Aj Wilson is offline  
Closed Thread


Bookmarks

Tags
experts, magento, php


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT -6. The time now is 06:40 PM.