Magento Forum

   
[SOLVED] Help with category images and a few other design snags
 
melvynanderson
Jr. Member
 
Total Posts:  20
Joined:  2012-12-24
 

Our site is located at http://www.melvynanderson.com

[Note:  I didn’t design this site and inherited it and all its problems recently.  I am not super familiar with Magento’s file structure or theme/layout scheme, so bare with me.  I’m mostly a CSS/HTML guy, so XML and PHP are a bit over my head.]

The site is using a theme called “fly” which has been modified.

Main issue at the moment is that on our main page, previously there was a call to “cat_images.phtml” which would query our categories and display a grid on the front page similar to what we have now.  Unfortunately in a move between servers, this file was causing a syntax error and the person that was editing it just went in and manually did a table on the main page.  Obviously that’s causing problems now that I need to add more categories to the main page.  Can anyone offer some advice on how to get that working again?

 
Magento Community Magento Community
Magento Community
Magento Community
 
Lyonscg
Sr. Member
 
Avatar
Total Posts:  173
Joined:  2009-11-13
Chicago IL
 

When you say they just went in and made a table on the home page, are you saying they did it in the CMS page or the template file? I guess an easier way of saying this is, did they modify the home page via the admin panel or via the backend code?

 
Magento Community Magento Community
Magento Community
Magento Community
 
melvynanderson
Jr. Member
 
Total Posts:  20
Joined:  2012-12-24
 

Sorry I haven’t responded sooner, I didn’t realize this posted because I got an error originally.

He went into the CMS and just did an unordered list, showing each category image within an <LI> tag on the home page.  It works, but it’s a bit inelegant.

Here’s the code from the cat_images.phtml file if it helps.

<div class="mid-content-images"><ul><?php    // We'll use this view of the database in a
second to load the individual categories    $_model Mage::getModel('catalog/category'); 
  
// Using the "catalog/navigation" Block Classes, we can invoke the getStoreCategories()
method to get all Store Cats.    $_categories $this->getStoreCategories();    // We'll
loop through the returned Category Object    foreach($_categories as $_category){       
// Using the Category Model, we'll load the category in the loop        $_currentCat =
$_model->load($_category->getId());        //$thumbUrl = ('catalog/category')->load(
$_currentCat->getId())->getThumbnailUrl();        $thumbUrl =
Mage::getModel('catalog/category')->load($_currentCat->getData('id'))->getThumbnailUrl();
        
?>        <li>  <div class="banner-right-image">        <?php        // If there
is an image in the Category object, use the getImageUrl() method to get the full URL to
the image
.        if($_currentCat->getData('image')) {?>         <a href="<?php echo
$_currentCat->getData("url_path")?>">         <img src="<?php echo
$_currentCat->getThumbnailUrl(); ?>" alt="<?php echo $_currentCat->getData('name') ?>"
border="0" class="image-effact" />        <div class="mid-content-image-text"<?php echo
$_currentCat->getData('name'?></div> </a>       <?php } ?>      
</div></li>        <?php } ?></ul> <div class="clear"></div></div>

 
Magento Community Magento Community
Magento Community
Magento Community
 
nathus
Sr. Member
 
Total Posts:  93
Joined:  2008-12-13
Twin Cities, MN
 

Is that how the code is formatted in the file?

In your pasted code, the start of a line of code is commented out.

Also, there is some code where you are loading a model a second time, and not using it. I reformatted it from your post, just in case that was the problem. If that doesn’t fix it, could you post the actual syntax error you are getting?

<div class="mid-content-images">
    <
ul>
    
<?php    
    
// We'll use this view of the database in a second to load the individual categories    
    
$_model Mage::getModel('catalog/category'); 

    
// Using the "catalog/navigation" Block Classes, we can invoke the getStoreCategories() method to get all Store Cats.    
    
$_categories $this->getStoreCategories();    

    
// We'll loop through the returned Category Object    
    
foreach($_categories as $_category){       
        
// Using the Category Model, we'll load the category in the loop        
        
$_currentCat $_model->load($_category->getId());        
        
//$thumbUrl = ('catalog/category')->load($_currentCat->getId())->getThumbnailUrl();        
        //$thumbUrl = Mage::getModel('catalog/category')->load($_currentCat->getData('id'))->getThumbnailUrl();
    
?>        
    
<li>
        <
div class="banner-right-image">
        
<?php        
        
// If there is an image in the Category object, use the getImageUrl() method to get the full URL to the image.        
        
if($_currentCat->getData('image')) {?>
            
<a href="<?php echo $_currentCat->getData("url_path")?> ">
                <
img src="<?php echo $_currentCat->getThumbnailUrl(); ?>" alt="<?php echo $_currentCat->getData('name') ?>" border="0" class="image-effact" />
                <
div class="mid-content-image-text"
                
<?php echo $_currentCat->getData('name'?></div>
            </
a>
        
<?php } ?>      
        
</div>
    </
li>        
    
<?php } ?>
    
</ul>
    <
div class="clear"></div>
</
div>

 
Magento Community Magento Community
Magento Community
Magento Community
 
melvynanderson
Jr. Member
 
Total Posts:  20
Joined:  2012-12-24
 

That worked perfectly actually.  I noticed the same thing and have been trying to format it correctly, but your version fixed it.

I think I need to play around with my margins now, one row is getting pushed over.

http://www.melvynanderson.com/

Inspecting it looks like theres an extra list item getting in there somehow, but I think I can fix that up.

Thank you for the help, I really appreciate it.

[EDIT]

Problem turned out to be that a category didn’t have a proper thumbnail image.  All fixed up now.  Thank you again, I appreciate it very much.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top