+ Reply to Thread
Results 1 to 9 of 9

Thread: Subcategory Images

  1. #1
    Client
    Join Date
    Nov 2007
    Posts
    182
    Squirrelcart version
    v3.2.0

    Question Subcategory Images

    If you click on the category in left menu and then see the subcategories, how do I make the subcategories as images? I used to use the Thumbnail_Image for it, but I am using this to show buttons in the menu.

  2. #2
    Squirrelcart Staff Jamie's Avatar
    Join Date
    May 2002
    Posts
    6,829
    Squirrelcart version
    v3.3.7
    We don't have a built in feature to do that. You could try modifying the product_catalog_nav.tpl.php template file and add a variable corresponding to one of the image fields on your category records. This post explains some of those variables and how to reference them:
    http://www.ldev.com/forums/showthread.php?t=4153

  3. #3
    Client
    Join Date
    Nov 2007
    Posts
    182
    Squirrelcart version
    v3.2.0
    Thanks! I modified the product_catalog_nav.tpl.php file and hardcoded my links and used the Thumbnail_Image for my subcategories.

  4. #4
    Client
    Join Date
    Feb 2004
    Location
    Ozark Mts
    Posts
    39
    Squirrelcart version
    v2.4.1
    Or you could upload a thumbnail for each subcategory and modify the subcategory.tpl.php to this

    Code:
    <?php /* This line prevents direct access to template. Don't remove it. */ if (!defined('SC_INCLUDE_OK')) die; ?>
    <!-- Template: <?php print basename(__FILE__) ?> -->
    
    <div class="subcategory">
    <img src="<?php print $Thumbnail_Image['dyn'] ?>" alt="<?php print $Thumbnail_Image['alt'] ?>" width="<?php print $Thumbnail_Image['width'] ?>" height="<?php print $Thumbnail_Image['height'] ?>" />
    <br>
    	<a href="<?php print $URL ?>" title="<?php print $Link_Title ?>"><?php print $Name ?></a>
    </div>
    It seems to be working for me pretty well, but I haven't had much time for a thorough check.
    ~~~~~
    Tammy
    ~~~~~

  5. #5
    Client
    Join Date
    Feb 2004
    Location
    Ozark Mts
    Posts
    39
    Squirrelcart version
    v2.4.1

    Subcategory Images

    If you want to add images to the subcategories and hyperlink them to the subcategory page like the text link, then replace with this code instead of the above:

    Code:
    <?php /* This line prevents direct access to template. Don't remove it. */ if (!defined('SC_INCLUDE_OK')) die; ?>
    <!-- Template: <?php print basename(__FILE__) ?> -->
    
    <div class="subcategory">
    <a href="<?php print $URL ?>" title="<?php print $Link_Title ?>">
    <img src="<?php print $Thumbnail_Image['dyn'] ?>" alt="<?php print $Thumbnail_Image['alt'] ?>" width="<?php print $Thumbnail_Image['width'] ?>" height="<?php print $Thumbnail_Image['height'] ?>" /> </a>
    <br>
    	<a href="<?php print $URL ?>" title="<?php print $Link_Title ?>"><?php print $Name ?></a>
    </div>
    ~~~~~
    Tammy
    ~~~~~

  6. #6
    Client
    Join Date
    Mar 2005
    Posts
    14
    Squirrelcart version
    not specified!
    Quote Originally Posted by enchantedneedle View Post
    If you want to add images to the subcategories and hyperlink them to the subcategory page like the text link, then replace with this code instead of the above:

    Code:
    <?php /* This line prevents direct access to template. Don't remove it. */ if (!defined('SC_INCLUDE_OK')) die; ?>
    <!-- Template: <?php print basename(__FILE__) ?> -->
    
    <div class="subcategory">
    <a href="<?php print $URL ?>" title="<?php print $Link_Title ?>">
    <img src="<?php print $Thumbnail_Image['dyn'] ?>" alt="<?php print $Thumbnail_Image['alt'] ?>" width="<?php print $Thumbnail_Image['width'] ?>" height="<?php print $Thumbnail_Image['height'] ?>" /> </a>
    <br>
    	<a href="<?php print $URL ?>" title="<?php print $Link_Title ?>"><?php print $Name ?></a>
    </div>

    Tammy, this works soooooo perfect. This should definitely be coded into SC as an option under categories. Thanks for the great fix!

  7. #7
    Client
    Join Date
    Nov 2007
    Posts
    182
    Squirrelcart version
    v3.2.0
    I have thumbnail images so my subcategories have images on the category page. The images show in Firefox, but they don't show in IE8.

    This is the code I have in my subcategory.tpl.php file:

    <div class="subcategory">
    <a href="<?php print $URL ?>" title="<?php print $Link_Title ?>"><img src="<?php print $Thumbnail_Image['dyn'] ?>" <?php print $Thumbnail_Image['dims'] ?> alt="<?php print $Thumbnail_Image['alt'] ?>" /><p><?php print $Name ?></p></a>
    </div>

    Any ideas why they don't show in IE8?

  8. #8
    Client
    Join Date
    Nov 2007
    Posts
    182
    Squirrelcart version
    v3.2.0
    I used Tammy's code and now it shows. Thanks Tammy!

  9. #9
    Registered User ljcaswell's Avatar
    Join Date
    Apr 2010
    Posts
    14
    Squirrelcart version
    v3.4.1
    This worked great for me except that I was getting image missing placeholders on some browsers where the image for a certain category wasn't set. I added an if statement to check if the image has been set.

    PHP Code:
    <div class="subcategory">
    <a href="<?php print $URL ?>" title="<?php print $Link_Title ?>">
    <?php if($Thumbnail_Image['dyn']) { ?>
    <img src="<?php print $Thumbnail_Image['dyn'?>" alt="<?php print $Thumbnail_Image['alt'?>" width="<?php print $Thumbnail_Image['width'?>" height="<?php print $Thumbnail_Image['height'?>" /> </a>
    <br>
    <?php ?>
            <a href="<?php print $URL ?>" title="<?php print $Link_Title ?>"><?php print $Name ?></a>
    </div>

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts