alkarim
Total Posts: 368
Joined: 2008-04-10
hi, really need your help
how to get category name with sub category at Mage->catalog->Block->Product->NewHTML.php
Posted: June 9 2008
| top
sherrie
Total Posts: 1652
Joined: 2007-12-14
Illinois, USA
Can you please elaborate on your question or give us an image to work off of?
I’m not really sure what you are asking right now.
Signature
UX Manager, Sweet Tooth
Creativity is falling in love with the world. – Dewitt Jones
I’m a very random person, catch me if you can: http://www.twitter.com/sherrierohde
Posted: June 9 2008
| top
| # 1
alkarim
Total Posts: 368
Joined: 2008-04-10
hi @sherrie,
I’m working at CMS->Manage Pages->homepage using block. At the homepage I’m going to display Items image, price, title, product’s url, and the category’s url.
at this point I’m only confuse to display the category’s url. The problem is “how to get the category’s url”
thanks for your reply
Posted: June 10 2008
| top
| # 2
sherrie
Total Posts: 1652
Joined: 2007-12-14
Illinois, USA
You can figure out the category ID by going to Manage Categories and clicking on the category you need the ID for - when it loads that category to edit it, you will see the category ID in the address bar of your browser. Hopefully that’s what you’re asking, I’m still not quite sure.
Signature
UX Manager, Sweet Tooth
Creativity is falling in love with the world. – Dewitt Jones
I’m a very random person, catch me if you can: http://www.twitter.com/sherrierohde
Posted: June 10 2008
| top
| # 3
alkarim
Total Posts: 368
Joined: 2008-04-10
Um, arghh, got wrong place to ask but Its not what I’m talking about.. anyway thanks.
actually I need a code to get the category url,
Posted: June 11 2008
| top
| # 4
lotusseedsD
Total Posts: 1144
Joined: 2007-08-31
Not 100% sure but you may want to play with this code (copy from ‘left.phtml’)
<?php foreach ( $_categories as $_category ): ?> <?php if( $_category -> getIsActive ()): ?> < li > < a href = "<?php echo $this->getCategoryUrl($_category) ?>" <?php if ( $this -> isCategoryActive ( $_category )): ?> class= "active" <?php endif ?> > <?php echo $this -> htmlEscape ( $_category -> getName ()) ?> </ a > ( <?php echo $_category -> getProductCount () ?> ) </ li > <?php endif; ?> <?php endforeach ?>
Signature
Accessible, WCAG 2.0 HTML5 Magento/WordPress Development & Magento themes:
Latest release : Green Path Premium Theme | : Touchscreen Optimized Mobile Theme
Posted: June 11 2008
| top
| # 5
alkarim
Total Posts: 368
Joined: 2008-04-10
it’s perfect @chinesedream,
is there another code that get the product category and its sub-category ?
thanks for your quick reply
Posted: June 11 2008
| top
| # 6
lotusseedsD
Total Posts: 1144
Joined: 2007-08-31
This is what I got for sub-categories
< div class= "cat-nav-table" > <?php $i = 0 ; foreach ( $this -> getCurrentChildCategories () as $_childCategory ): ?> <?php if ( $i > 12 ): continue; endif; ?> < ul class= "model" > < li > < a href = "<?=$this->getCategoryUrl($_childCategory)?>" <?if ( $this -> isCategoryActive ( $_childCategory )): ?> class= "activeNav" <?endif?> > < img src = "<?=$_childCategory->getImageUrl()?>" alt = "<?=$_childCategory->getName()?>" /> </ a > </ li > < li > <? = $_childCategory -> getName () ?> </ li > </ ul > <?php $i ++; endforeach; ?> <?php for( $i ; $i & #x12;!=0;$i++): ?> <?php endfor ?> < div class= "clear" ></ div > </ div >
Signature
Accessible, WCAG 2.0 HTML5 Magento/WordPress Development & Magento themes:
Latest release : Green Path Premium Theme | : Touchscreen Optimized Mobile Theme
Posted: June 11 2008
| top
| # 7
alkarim
Total Posts: 368
Joined: 2008-04-10
thanks,
$this->getCurrentChildCategories() always give me an error, I don’t know why. It says : Error Submission Form,
Posted: June 11 2008
| top
| # 8
alkarim
Total Posts: 368
Joined: 2008-04-10
I need to get a product category and its sub-category, not current category..
means that : I make a new homepage, that could have the ability to show all products’ name, price, category, image.
so , I need to make a function to create that.
Now , I can get the category_ids of a product
$_product -> _data[ 'category_ids' ]
but it is only give the category id, not its category name and sub-category name…
Posted: June 11 2008
| top
| # 9
alkarim
Total Posts: 368
Joined: 2008-04-10
hi I created this code :
$_categories = Mage :: helper ( 'catalog/category' )-> getStoreCategories (); $_categories_name = $_categories_path = array(); foreach ( $_categories as $_category ) : $aIdxs = explode ( ',' , Mage :: getModel ( 'catalog/category' )-> setData ( $_category -> getData ())-> getAllChildren ()); //echo Mage::helper('catalog/category')->drawItemAll($_category).$_category->getId(); if ( $_category -> getIsActive ()) : foreach ( $aIdxs as $idx => $iCatIdx ) : if ( $iCatIdx > 2 ) { $_categories_name[$iCatIdx] = $this -> htmlEscape ( $_category -> getName ()); $_categories_path[$iCatIdx] = Mage :: getModel ( 'catalog/category' )-> setData ( $_category -> getData ())-> getUrl (); } endforeach; endif; endforeach;
I don’t know if this code is good enough or not…
please, someone tell me…
thanks