osCmax v2.5 User Manual
Results 1 to 8 of 8

Moving category links to main area

This is a discussion on Moving category links to main area within the osCommerce 2.2 Modification Help forums, part of the osCommerce 2.2 Forums category; I've seen a number of OSC sites that have the main categories as graphical links in the body of the ...

      
  1. #1
    Lurker
    Join Date
    May 2003
    Posts
    1
    Rep Power
    0


    Default Moving category links to main area

    I've seen a number of OSC sites that have the main categories as graphical links in the body of the front page rather than just stuck up in the top left corner as text links. I've managed to insert my category graphics onto the front page (by adding HTML to catalog/languages/english/default.php) but I don't know what PHP code I need to add in order to turn them into links to the categories.

    This seems like a fairly common thing to want to do, but I haven't come across any solution to it. Anyone's assistance would be greatly appreciated.

  2. #2
    Lurker
    Join Date
    Aug 2003
    Location
    Wisconsin
    Posts
    2
    Rep Power
    0


    Default Did you...

    Did you find a way to do this yet? I have to do it also, and would like to do it dynamically also....

    JC

  3. #3
    New Member
    Join Date
    Jul 2003
    Posts
    26
    Rep Power
    0


    Default

    not sure if this is what you're looking for but this is a link that should work
    to call the product directly the link would be somethig like this
    Code:
    product_info.php?products_id=17
    product_id=Your_Product_Id
    and to call individual categories the link woul look like this
    Code:
    index.php?cPath=1
    cPath=Your_Cat_Id
    and to call an individual subcategory page the link would look like this
    Code:
    index.php?cPath=1_8
    cPath=Your Main Cat Id_Your Sub Cat Id
    so for example to call a page I.E a deafault setup of osc and you want to show the hardware graphics card your html code would be something like this
    Code:
    <a href="index.php?cPath=1_4"><img src="images/your_image_path/your_image_name.gif"></a>
    that should do the trick.
    Let me know if it works out for you

  4. #4
    Lurker zogster's Avatar
    Join Date
    Feb 2004
    Location
    Oxford, UK
    Posts
    2
    Rep Power
    0


    Default

    Hi
    Quite new at this. The above answer looks like you have to manually change the html if you update you category structure.

    I edited the index.php file that creates either the front page, the category pages or the final product pages and butchered the text used to create the category page and pasted it at the bottom of the front page text. This enable the categories to be created dynamically and reduces the manual recoding. If you are interested, let me know and I'll post up the file.

    I don't follow every command in php yet and therefore don't guarantee the butchering is bug free, but so far so good for me.

  5. #5
    New Member
    Join Date
    Mar 2004
    Posts
    20
    Rep Power
    0


    Default Categories on Main Page

    Hi Zogster,

    I'd be interested in seeing what you've done. I'm new to PHP, but it looks as if a link to http://www.YOUR_DOMAIN.com/catalog/index.php?cPath=0
    will list all the categories. I'm not sure yet how (if possible) to make index.php crank up automatically with a cPath=0. Sounds like you've worked around it. Where did you get the categories code? The only categories.php files I've seen seem to all be admin related. I don't see (but I'll start a concerted effort at finding) the code you're talking about.

    In includes/boxes/categories.php, there's some code for displaying the categories. Is that what you're talking about? I'm going to play with it.

    Thanks for the inspiration...

  6. #6
    Lurker zogster's Avatar
    Join Date
    Feb 2004
    Location
    Oxford, UK
    Posts
    2
    Rep Power
    0


    Default

    Hi Xtech

    I edited the index.php file in the main catalog root folder. This file either displays the welcome page, the category list or the product list depending upon where you are. All the actual contents are pulled in from other files but this is the file that puts it all together and slaps it on the screen.

    The file is built up like so:

    Code:
    Header
    Left Column
       Either
            Categories List or
            Product List or
            Welcome page
    Right Column
    Footer
    This main question in the middle of the file is controlled using an if ... elseif... else statement and looks at the 'breadcrumb trail' to tell the program where in the structure the customer is right now.

    I therefore copied a chunk of the code that is used in the category list section and inserted it at the bottom of the Welcome page section. A little bit of tweaking was required. I don't currently have any real understanding of PHP but a reasonable grasp of HTML and basic programming in the past helped to show the way for this tweaking and I ended up with the following code:

    Code:
    <?php
        $category_query = tep_db_query("select cd.categories_name, c.categories_image from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = '" . (int)$current_category_id . "' and cd.categories_id = '" . (int)$current_category_id . "' and cd.language_id = '" . (int)$languages_id . "'");
        $category = tep_db_fetch_array($category_query);
    ?>
    	<tr>
        <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0">
          <tr>
    <?php
          $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 = '" . (int)$current_category_id . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' order by sort_order, cd.categories_name");
        $number_of_categories = tep_db_num_rows($categories_query);
    
        $rows = 0;
        while ($categories = tep_db_fetch_array($categories_query)) {
          $rows++;
          $cPath_new = tep_get_path($categories['categories_id']);
          $width = (int)(100 / MAX_DISPLAY_CATEGORIES_PER_ROW) . '%';
          echo '                <td align="center" width="' . $width . '" valign="bottom"><a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_new) . '">' . tep_image(DIR_WS_IMAGES . $categories['categories_image'], $categories['categories_name'], SUBCATEGORY_IMAGE_WIDTH, SUBCATEGORY_IMAGE_HEIGHT) . '</a></td>' . "\n";
          if ((($rows / MAX_DISPLAY_CATEGORIES_PER_ROW) == floor($rows / MAX_DISPLAY_CATEGORIES_PER_ROW)) && ($rows != $number_of_categories)) {
            echo '              </tr>' . "\n";
            echo '              <tr>' . "\n";
          }
        }
    
    // needed for the new products module shown below
    /*    $new_products_category_id = $current_category_id;*/
    ?>
    
          </tr>
            </table>
    </table>
    Remember I didn't write this just copied it from earlier in the file and tweaked it (in most cases deleted bits no longer needed).

    Like I say, I put this under the main text on my 'Welcome' page and it works for me. I have four main categories and no subcategories. I have removed the text for each category heading and inserted nice icons/buttons instead, using the category image field in the admin.

    The hardest bit was sorting out the <table>...</table> html coding as you have to follow it all the way through the whole file (or you can cheat and trial and error it) but i got there in the end anyway.

    To see the finished result try http://www.jollyfungus.com/shop
    The store is not live yet, but feel free to comment anyway

    Remember I'm a nOOb too so this may not be the only way to achieve this. If I can help any more please let me know, only too happy to help.

    Zogster

  7. #7
    New Member
    Join Date
    Mar 2004
    Posts
    20
    Rep Power
    0


    Default

    Hi again Zogster,

    I tried what you mentioned, but I think I'm being stupid. I'm going to play with it again because that feature will come in handy. I solved my problem - thanks in good part to your direction to index.php. I was helping somone who wanted their existing products page to be the shopping cart, but they wanted absolutely no functionality other than to list their products and be able to buy them. Basically "Don't change our site look at all (even though it is hideous, IMO) but we want to add "Buy Now" capability to our "Products" page - which is just a list of products." The way they've structured things, what that really means is "Display a list of all product categories".

    My solution wound up being to add the following line to the top of index.php

    $cPath = '0';

    As it states in index.php, the cPath values are coming from application_top.php. I just overrode that value first thing, which makes all categories display instead of mainpage. This wouldn't work for what you were doing, because you still wanted the welcome message. These peeps didn't want the welcome message or anything - just the categories. They'll link to the cart from their "Products" page.

    I didn't understand how that worked, so I was going to try doing as you suggested and then remove all welcome stuff. My stupidity wound up saving me some time, as the one line change is perfect for what they wanted.

    Still, I want to play with your code paste for future reference.

    Thanks again for being so helpful!

  8. #8
    Member
    Join Date
    May 2005
    Location
    Berkshire, UK
    Posts
    56
    Rep Power
    0


    Default

    remember to test your links to ensure the session id is being carried over with your new links - this may depend on if you force cookies or not.

Similar Threads

  1. how to change color/size of links within main page
    By joanstead in forum osCmax v2 Customization/Mods
    Replies: 3
    Last Post: 02-09-2006, 01:19 PM
  2. Help with Main Category Display
    By azimpact in forum osCommerce 2.2 Modification Help
    Replies: 0
    Last Post: 11-30-2005, 01:10 PM
  3. Product links in define main page not working
    By developer_x in forum osCommerce 2.2 Modification Help
    Replies: 1
    Last Post: 02-24-2005, 11:17 AM
  4. HELP! How do I change the Category html links??
    By acreativepage in forum osCommerce 2.2 Modification Help
    Replies: 3
    Last Post: 05-09-2004, 02:44 AM
  5. category Icons with links on the main page
    By CMWM in forum osCMax v1.7 General Mods Discussion
    Replies: 1
    Last Post: 04-06-2004, 07:02 AM

Bookmarks

Posting Permissions

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