Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

How To Turn Menu/Product LInks Into Buttons?


jbh

Recommended Posts

Hello. I did a search, somebody else asked this a while back 3 times. Is there any solution for the left side box to have button links instead of text links? I am surprised nobody would know...

Link to comment
Share on other sites

Hello, jbh

I haven't tried this with Osc however I use in with html pages so the following code for buttons could be able to be added to the style sheet. You would change the colours and size to suit your situation.

.myButton {

margin-bottom: 4px;

font-weight: bold;

font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;

font-size: 12px;

}

 

.myButton a:link {

padding: 4px;

text-decoration: none;

width: 130px;

display: block;

color: #4E908F;

background-color: #99CCCC;

border-top: 2px #E9E9E9 solid;

border-left: 2px #E9E9E9 solid;

border-bottom: 2px #8E8E8E solid;

border-right: 2px #8E8E8E solid;

 

}

 

.myButton a:visited {

padding: 4px;

text-decoration: none;

width: 130px;

display: block;

color: #4E908F;

background-color: #99CCCC;

border-top: 2px #E9E9E9 solid;

border-left: 2px #E9E9E9 solid;

border-bottom: 2px #8E8E8E solid;

border-right: 2px #8E8E8E solid;

 

}

 

.myButton a:hover {

padding: 4px;

text-decoration: none;

width: 130px;

display: block;

color: #4E908F;

background-color: #99CCCC;

border-top: 2px #8E8E8E solid;

border-left: 2px #8E8E8E solid;

border-bottom: 2px #E9E9E9 solid;

border-right: 2px #E9E9E9 solid;

 

}

 

.myButton a:active {

padding: 4px;

text-decoration: none;

width: 100px;

display: block;

color: #4E908F;

background-color: #ECF6F6;

border-top: 2px #E9E9E9 solid;

border-left: 2px #E9E9E9 solid;

border-bottom: 2px #8E8E8E solid;

border-right: 2px #8E8E8E solid;

 

}

 

Hope you find this of some use.

 

korsh

Link to comment
Share on other sites

Hello James,

 

Since I wanted to know the same thing, I've been watching this topic. Thanks for your input. Do you suppose that you could post a link to a site you've used this on, so I could see what it is supposed to do? I pasted it into an html document and took a peek and all that shows is all the text... no buttons.

 

Victoria

brand new php-er

Link to comment
Share on other sites

Hello Victoria,

 

It does take a little playing around with to get it right.

Here is an example.

 

My Button

 

Although I have made the link refer back to itself, the button works just fine.

 

hope this helps

 

James

Link to comment
Share on other sites

Here is some code to use buttons instead of text links

 

<?php
/*
 $Id: categories.php,v 1.2 2002/11/29 00:31:55 wilt Exp $

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2002 osCommerce

 Released under the GNU General Public License
*/

 function tep_show_category($counter) {
   global $foo, $categories_string, $id;

   for ($a=0; $a<$foo[$counter]['level']; $a++) {
     $categories_string .= "  ";
   }

   $categories_string .= '<table width="100%" cellpadding="0" cellspacing="0" border-"0"><tr><td height="40" class="main" align="center"><a href="';

   if ($foo[$counter]['parent'] == 0) {
     $cPath_new = 'cPath=' . $counter;
   } else {
     $cPath_new = 'cPath=' . $foo[$counter]['path'];
   }

   $categories_string .= tep_href_link(FILENAME_DEFAULT, $cPath_new);
   $categories_string .= '">';
$categories_string .= tep_image( DIR_WS_IMAGES . $foo[$counter]['image'], $foo[$counter]['name']);
// . '</a></td>';
//$categories_string .= '<td width="10"></td>';
//$categories_string .=  '<td class="main"><a href="';

//$categories_string .= tep_href_link(FILENAME_DEFAULT, $cPath_new);
   //$categories_string .= '">';
/*	
   if ( ($id) && (in_array($counter, $id)) ) {
     $categories_string .= '<b>';
   }

// display category name
   $categories_string .=  $foo[$counter]['name'];

   if ( ($id) && (in_array($counter, $id)) ) {
     $categories_string .= '</b>';
   }
*/
  /* if (tep_has_category_subcategories($counter)) {
     $categories_string .= '->';
   }*/

   $categories_string .= '</a>';

   if (SHOW_COUNTS == 'true') {
     $products_in_category = tep_count_products_in_category($counter);
     if ($products_in_category > 0) {
       $categories_string .= ' (' . $products_in_category . ')';
     }
   }

   $categories_string .= '</td></tr></table>';

   if ($foo[$counter]['next_id']) {
     tep_show_category($foo[$counter]['next_id']);
   }
 }
?>
<!-- categories //-->
         <tr>
           <td>
<?php
 /*$info_box_contents = array();
 $info_box_contents[] = array('align' => 'left',
                              'text'  => BOX_HEADING_CATEGORIES
                             );
 new infoBoxHeading($info_box_contents, true, false);
*/
 $categories_string = '';

 $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='" . $languages_id ."' order by sort_order, cd.categories_name");
 while ($categories = tep_db_fetch_array($categories_query))  {
   $foo[$categories['categories_id']] = array(
                                       'name' => $categories['categories_name'],
                                       'parent' => $categories['parent_id'],
                                       'level' => 0,
                                       'path' => $categories['categories_id'],
         'image' => $categories['categories_image'],
                                       'next_id' => false
                                      );

   if (isset($prev_id)) {
     $foo[$prev_id]['next_id'] = $categories['categories_id'];
   }

   $prev_id = $categories['categories_id'];

   if (!isset($first_element)) {
     $first_element = $categories['categories_id'];
   }
 }

 //------------------------
 if ($cPath) {
$new_path = '';
   $id = split('_', $cPath);
   reset($id);
   while (list($key, $value) = each($id)) {

     unset($prev_id);
     unset($first_id);
     $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 = '" . $value . "' and c.categories_id = cd.categories_id and cd.language_id='" . $languages_id ."' order by sort_order, cd.categories_name");
     $category_check = tep_db_num_rows($categories_query);
     if ($category_check > 0) {           
      $new_path .= $value;
     while ($row = tep_db_fetch_array($categories_query)) {
       $foo[$row['categories_id']] = array(
                                           'name' => $row['categories_name'],
                                           'parent' => $row['parent_id'],
                                           'level' => $key+1,
                                           'path' => $new_path . '_' . $row['categories_id'],
        	 'image' => $categories['categories_image'],
                                           'next_id' => false
                                          );

       if (isset($prev_id)) {
         $foo[$prev_id]['next_id'] = $row['categories_id'];
       }

       $prev_id = $row['categories_id'];

       if (!isset($first_id)) {
         $first_id = $row['categories_id'];
       }

       $last_id = $row['categories_id'];
     }

       $foo[$last_id]['next_id'] = $foo[$value]['next_id'];
       $foo[$value]['next_id'] = $first_id;


     $new_path .= '_';
     } else {
  break;
   }
 }
}
 tep_show_category($first_element); 

 $info_box_contents = array();
 $info_box_contents[] = array('align' => 'left',
                              'text'  => $categories_string
                             );
 new infoBox($info_box_contents);
?>
           </td>
         </tr>
<!-- categories_eof //-->

 

 

this will use the category image as the button. If you prefer not to use the category image then you can make a new field in table categories and use that instead.

Link to comment
Share on other sites

code in /catalog/includes/boxes/categories.php to create buttons for category box:

 

<?php

/*

  $Id: categories.php,v 1.25 2003/07/09 01:13:58 hpdl Exp $

 

  osCommerce, Open Source E-Commerce Solutions

  http://www.oscommerce.com

 

  Copyright © 2003 osCommerce

 

  Released under the GNU General Public License

*/

 

  function tep_show_category($counter) {

    global $tree, $categories_string, $cPath_array;

 

    for ($i=0; $i<$tree[$counter]['level']; $i++) {

      $categories_string .= "  ";

    }

 

    $categories_string .= '<input type="button" onClick="java script:location.href=\'';

 

    if ($tree[$counter]['parent'] == 0) {

      $cPath_new = 'cPath=' . $counter;

    } else {

      $cPath_new = 'cPath=' . $tree[$counter]['path'];

    }

 

    $categories_string .= tep_href_link(FILENAME_DEFAULT, $cPath_new) . '\'"';

 

    if (isset($cPath_array) && in_array($counter, $cPath_array)) {

   

    }

 

// display category name

    $categories_string .= ' value="' . $tree[$counter]['name'];

 

    if (isset($cPath_array) && in_array($counter, $cPath_array)) {

   

    }

 

    if (tep_has_category_subcategories($counter)) {

      $categories_string .= '->';

    }

 

    if (SHOW_COUNTS == 'true') {

      $products_in_category = tep_count_products_in_category($counter);

      if ($products_in_category > 0) {

        $categories_string .= ' (' . $products_in_category . ')';

      }

    }

    $categories_string .= '">';

    $categories_string .= '<br>';

 

    if ($tree[$counter]['next_id'] != false) {

      tep_show_category($tree[$counter]['next_id']);

    }

 

  }

?>

<!-- categories //-->

          <tr>

            <td>

<?php

  $info_box_contents = array();

  $info_box_contents[] = array('text' => BOX_HEADING_CATEGORIES);

 

  new infoBoxHeading($info_box_contents, true, false);

 

  $categories_string = '';

  $tree = array();

 

  $categories_query = tep_db_query("select c.categories_id, cd.categories_name, 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");

  while ($categories = tep_db_fetch_array($categories_query))  {

    $tree[$categories['categories_id']] = array('name' => $categories['categories_name'],

                                                'parent' => $categories['parent_id'],

                                                'level' => 0,

                                                'path' => $categories['categories_id'],

                                                'next_id' => false);

 

    if (isset($parent_id)) {

      $tree[$parent_id]['next_id'] = $categories['categories_id'];

    }

 

    $parent_id = $categories['categories_id'];

 

    if (!isset($first_element)) {

      $first_element = $categories['categories_id'];

    }

  }

 

  //------------------------

  if (tep_not_null($cPath)) {

    $new_path = '';

    reset($cPath_array);

    while (list($key, $value) = each($cPath_array)) {

      unset($parent_id);

      unset($first_id);

      $categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . (int)$value . "' and c.categories_id = cd.categories_id and cd.language_id='" . (int)$languages_id ."' order by sort_order, cd.categories_name");

      if (tep_db_num_rows($categories_query)) {

        $new_path .= $value;

        while ($row = tep_db_fetch_array($categories_query)) {

          $tree[$row['categories_id']] = array('name' => $row['categories_name'],

                                              'parent' => $row['parent_id'],

                                              'level' => $key+1,

                                              'path' => $new_path . '_' . $row['categories_id'],

                                              'next_id' => false);

 

          if (isset($parent_id)) {

            $tree[$parent_id]['next_id'] = $row['categories_id'];

          }

 

          $parent_id = $row['categories_id'];

 

          if (!isset($first_id)) {

            $first_id = $row['categories_id'];

          }

 

          $last_id = $row['categories_id'];

        }

        $tree[$last_id]['next_id'] = $tree[$value]['next_id'];

        $tree[$value]['next_id'] = $first_id;

        $new_path .= '_';

      } else {

        break;

      }

    }

  }

  tep_show_category($first_element);

 

  $info_box_contents = array();

  $info_box_contents[] = array('text' => $categories_string);

 

  new infoBox($info_box_contents);

?>

            </td>

          </tr>

<!-- categories_eof //-->

 

Make a backup of your file before replacing.

Link to comment
Share on other sites

Thanks, Everybody.

 

Meltus, I have a question, if I May.

 

If I add a new field in the categories table called 'navbuttons'

do I just replace the table name in your queries from the above example to have them appear?

 

Thank you

Link to comment
Share on other sites

if you replace references to categories_image in the code to whatever you called your filed that would work.

 

then you would need to add an admin section or use phpmyadmin to update your images

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...