Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Link categories in main part of home page


aragorn231

Recommended Posts

My shop has 2 main categories. I would like to highlight these categories by putting a clickable image in the main part of my shop's home page.

 

What would be the best way to achieve this? I'm not really in favor of putting the category IDs in the code, because that would not make a clean and generic solution.

 

Your thoughts on this would be appreciated :rolleyes:

Link to comment
Share on other sites

My shop has 2 main categories.  I would like to highlight these categories by putting a clickable image in the main part of my shop's home page.

 

What would be the best way to achieve this?  I'm not really in favor of putting the category IDs in the code, because that would not make a clean and generic solution.

 

Your thoughts on this would be appreciated  :rolleyes:

 

 

there is a contribution for adding the main cats to the front page. I use it on the hollywood page (see my profile).

:-)

Monika

 

addicted to writing code ... can't get enough of databases either, LOL!

 

my toolbox: Textpad - Compare and Merge - phpMyAdmin - WS_FTP - Photoshop - How to search the forum

 

Interactive Media Award July 2007 ~ category E-Commerce

my advice on the forum is for free, PMs where you send me work are considered consultation which I charge for ...

Link to comment
Share on other sites

Great, that's indeed what I'm looking for! I already did a contribution search a couple of weeks ago, but couldn't really find it. I guess I wasn't so good in picking the keywords that day ;)

 

The contrib that you've used in your hollywood page, is that this one? Main categories in front page

Link to comment
Share on other sites

Great, that's indeed what I'm looking for!  I already did a contribution search a couple of weeks ago, but couldn't really find it.  I guess I wasn't so good in picking the keywords that day  ;)

 

The contrib that you've used in your hollywood page, is that this one? Main categories in front page

 

nope, it's this one:

http://www.oscommerce.com/community/contri...ategories+index

 

very easy to do!

:-)

Monika

 

addicted to writing code ... can't get enough of databases either, LOL!

 

my toolbox: Textpad - Compare and Merge - phpMyAdmin - WS_FTP - Photoshop - How to search the forum

 

Interactive Media Award July 2007 ~ category E-Commerce

my advice on the forum is for free, PMs where you send me work are considered consultation which I charge for ...

Link to comment
Share on other sites

Hello Monika,

 

Just gave it a try and it works fine!

 

I'll need to do some additional tweaking to get it to what I want (like possibility to hide some smaller head categories, and a layout that does not use the infoBox stuff - or at least does not look like the infoBox stuff - depending on what's easiest to implement). In your hollywood page, you've probably done something similar, right?

 

Anyways, thanks a lot for pointing me in the right direction.

:D

Link to comment
Share on other sites

Hello Monika,

 

Just gave it a try and it works fine!

 

I'll need to do some additional tweaking to get it to what I want (like possibility to hide some smaller head categories, and a layout that does not use the infoBox stuff - or at least does not look like the infoBox stuff - depending on what's easiest to implement).  In your hollywood page, you've probably done something similar, right?

 

Anyways, thanks a lot for pointing me in the right direction.

:D

 

 

yep, this is my file in modules:

 

<?php
/*
 $Id: new_products.php,v 1.34 2003/06/09 22:49:58 hpdl Exp $

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com
 Copyright (c) 2003 osCommerce
 Released under the GNU General Public License
 rewritten by Zoli Szucs May 23, 2004  
 last edited by Zoli Szucs October 8, 2004<[email protected]>
 Description:  originally this script loaded new products into the front page
 main box but now loads the top level category section
*/
?>
<!-- new_products //-->
<?php
 $info_box_contents = array();
 //puts title in the upper left corner of the new products box
 //$info_box_contents[] = array('text' => sprintf(BOX_HEADING_HOMEPAGE_CATEGORIES, strftime('%B')));
 
 //new contentBoxHeading($info_box_contents);  //puts the dark band on top of new products box
 //this select does not select the default categories and sub categories
 //the default categories have image titles like category_hardware.gif or subcategory_drama.gif
 //so to make sure your categories are selected, do NOT have "category" in the IMAGE title
 $categories_query =tep_db_query("select c.categories_id, cd.categories_name, c.categories_image, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '0' and c.categories_id = cd.categories_id and cd.language_id='" . (int)$languages_id ."' order by sort_order, cd.categories_name");
/*
SELECT c.categories_id, c.categories_image, c.sort_order, cd.categories_name
   FROM ".TABLE_CATEGORIES." AS c, ".TABLE_CATEGORIES_DESCRIPTION." AS cd
   WHERE c.categories_id = cd.categories_id AND c.categories_image NOT 
   LIKE  '%category%' AND cd.language_id  = 1 ORDER BY c.sort_order"); */

//to find the # of categories to be displayed which will serve as the uppper loop limit
 $num = mysql_num_rows($categories_query);
?>

     <tr>
       <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
         <tr>

<?php
     //variables to put the category images in rows and columns
     $row = 0;
     $col = 0;

     while($num)//keep doing while there catgories
     {    
       $rows =  mysql_fetch_array($categories_query);
       @$cPath_new =tep_get_path($rows['categories_id']);//error suppressor was need in cPanel but not DirectAdmin
       $new_products['products_name'] = tep_get_products_name($rows['categories_name']);    

    	 echo '<td align="center" width="33%" class="smallText" valign="top"><a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_new) . '">'. tep_image(DIR_WS_IMAGES . 'thumbs/' . $rows['categories_image'], $rows['categories_name'], '115', '') . '</a><br><a href="' .tep_href_link(FILENAME_DEFAULT, $cPath_new) .'">' . $rows['categories_name'].'</a><br></td>' . "\n";

       $col ++;
       if ($col > 2)
       {
         $col = 0;
         $row ++; 
?>
         </tr>
         <tr>
           <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
         </tr>
         <tr>
<?php
   }
       $num--;//keep subtracting until we're out of categories
     }       
   ?>
         </tr>
       </table></td>
     </tr>

:-)

Monika

 

addicted to writing code ... can't get enough of databases either, LOL!

 

my toolbox: Textpad - Compare and Merge - phpMyAdmin - WS_FTP - Photoshop - How to search the forum

 

Interactive Media Award July 2007 ~ category E-Commerce

my advice on the forum is for free, PMs where you send me work are considered consultation which I charge for ...

Link to comment
Share on other sites

I am wondering if it is possible to also get the categories showing in a table row in header.php?

 

well why not? use the same file I posted, steal the query and the display part from it and just omit the pics ...

:-)

Monika

 

addicted to writing code ... can't get enough of databases either, LOL!

 

my toolbox: Textpad - Compare and Merge - phpMyAdmin - WS_FTP - Photoshop - How to search the forum

 

Interactive Media Award July 2007 ~ category E-Commerce

my advice on the forum is for free, PMs where you send me work are considered consultation which I charge for ...

Link to comment
Share on other sites

well why not? use the same file I posted, steal the query and the display part from it and just omit the pics ...

Excellent Monika, I managed to get the code looking like this below. I am wondering where in amongst it all will the "|" go so that they can all go along one line like I have done with the information links (http://www.tallpoppycraft.com/catalog/index.php). My initial thought is that it has something to do with ""\n";"?

 

Sarah

 

<!-- new_products //-->
<?php
$info_box_contents = array();
//puts title in the upper left corner of the new products box
//$info_box_contents[] = array('text' => sprintf(BOX_HEADING_HOMEPAGE_CATEGORIES, strftime('%B')));

//new contentBoxHeading($info_box_contents);  //puts the dark band on top of new products box
//this select does not select the default categories and sub categories
//the default categories have image titles like category_hardware.gif or subcategory_drama.gif
//so to make sure your categories are selected, do NOT have "category" in the IMAGE title
$categories_query =tep_db_query("select c.categories_id, cd.categories_name, c.categories_image, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '0' and c.categories_id = cd.categories_id and cd.language_id='" . (int)$languages_id ."' order by sort_order, cd.categories_name");
/*
SELECT c.categories_id, c.categories_image, c.sort_order, cd.categories_name
  FROM ".TABLE_CATEGORIES." AS c, ".TABLE_CATEGORIES_DESCRIPTION." AS cd
  WHERE c.categories_id = cd.categories_id AND c.categories_image NOT 
  LIKE  '%category%' AND cd.language_id  = 1 ORDER BY c.sort_order"); */

//to find the # of categories to be displayed which will serve as the uppper loop limit
$num = mysql_num_rows($categories_query);
?>

    <tr>
      <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
        <tr>

<?php
    //variables to put the category images in rows and columns
    $row = 0;
    $col = 0;

    while($num)//keep doing while there catgories
    {    
      $rows =  mysql_fetch_array($categories_query);
      @$cPath_new =tep_get_path($rows['categories_id']);//error suppressor was need in cPanel but not DirectAdmin
      $new_products['products_name'] = tep_get_products_name($rows['categories_name']);    

     echo '<td align="left" width="0%" class="infoBoxContents" valign="top"><a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_new) . '">'. tep_image(DIR_WS_IMAGES . 'thumbs/' . $rows['categories_image'], $rows['categories_name'], '115', '') . '</a><a href="' .tep_href_link(FILENAME_DEFAULT, $cPath_new) .'">' . $rows['categories_name'].'</a><br></td>' . "\n";

      $col ++;
      if ($col > 0)
      {
        $col = 0;
        $row ++; 
?>
        </tr>
        <tr>
<?php
  }
      $num--;//keep subtracting until we're out of categories
    }       
  ?>
        </tr>
      </table></td>
    </tr></td>
   <td align="right" valign="bottom">

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...