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 ...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
|
#1
| |||
| |||
| 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. |
| Sponsored Links | ||
| ||
| |
|
#2
| |||
| |||
| 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
| |||
| |||
| 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 and to call individual categories the link woul look like this Code: index.php?cPath=1 and to call an individual subcategory page the link would look like this Code: index.php?cPath=1_8 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> Let me know if it works out for you |
|
#4
| ||||
| ||||
| 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
| |||
| |||
| 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
| ||||
| ||||
| 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
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>
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
| |||
| |||
| 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
| |||
| |||
| 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. |
| Sponsored Links | ||
| ||
| |
| Thread Tools | |
| |
| ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| how to change color/size of links within main page | joanstead | osCMax v2 Customization/Mods | 3 | 02-09-2006 01:19 PM |
| Help with Main Category Display | azimpact | osCommerce 2.2 Modification Help | 0 | 11-30-2005 01:10 PM |
| Product links in define main page not working | developer_x | osCommerce 2.2 Modification Help | 1 | 02-24-2005 11:17 AM |
| HELP! How do I change the Category html links?? | acreativepage | osCommerce 2.2 Modification Help | 3 | 05-09-2004 02:44 AM |
| category Icons with links on the main page | CMWM | osCMax v1.7 General Mods Discussion | 1 | 04-06-2004 07:02 AM |