Jump to content
Sign in to follow this  
smartwork

[New Contribution] All Categories / Subcategories

Recommended Posts

Based on the AllProds 2.3 contribution which lists all products on one page WITH keyword-loaded links/URLs for the purpose of spiders, this contribution does the same thing for categories and subcategories.

 

It produces one page with categories/subcategories listed with keyword-loaded links/URLs. Link to this page from all your others and let the spiders do their thing. This isn't intended for visitor use - can be, but not intended for.

 

This is my first contribution and I'm a rookie at php, so please be kind. :wink: It works on our 2.2 MS1 heavily loaded with other contributions - including the AllProds 2.3

 

http://www.oscommerce.com/community/contri...ons,1213/page,2

 

Hope it treats you well and is useful.

 

-shaun

Share this post


Link to post
Share on other sites

I picked up a small bug in this....

 

In catalog/allcategories.php change:

 

FILENAME_CATEGORIES_INFO

 

to

 

FILENAME_DEFAULT

 

Otherwise you will get a Page Cannot Found

Share this post


Link to post
Share on other sites

Oops.... thanks for catching it... but it the error was my forgetfullness. This should be added to application_top.php which will have the FILENAME_CATEGORIES_INFO remain the same. They both produce the same result though - regarding default.php

 

//BEGIN allcategories modification

define('FILENAME_CATEGORIES', 'allcategories.php');

define('FILENAME_CATEGORIES_INFO','default.php');

//END allcategories modification

 

I'll edit the README and update the contribution.

 

Thanks!

 

-shaun

Share this post


Link to post
Share on other sites

Not sure how useful this one will be (gonna check around more) but I have installed it.

 

Apart from the FILENAME_DEFAULT change above, I had to change this:

 

echo "     <a href="" . tep_href_link(FILENAME_DEFAULT, 'name=' .str_replace("/", "/", rawurlencode($this_categories_name)). "/" . "cPath/" . $categories_id . $this_categories_id . (($this_language_code == DEFAULT_LANGUAGE) ? '' : ('&language=' . $this_language_code)), 'NONSSL', false) . "">" . $this_categories_name . "</a>n";

 

to this:

 

echo "     <a href="" . tep_href_link(FILENAME_DEFAULT, 'name=' .str_replace("/", "/", rawurlencode($this_categories_name)). "&" . "cPath=" . $categories_id . $this_categories_id . (($this_language_code == DEFAULT_LANGUAGE) ? '' : ('&language=' . $this_language_code)), 'NONSSL', false) . "">" . $this_categories_name . "</a>n";

 

to get it to find the page correctly.

 

 

All Prods can be customised so that (even though it is for Search Engines) it can still look nice and be useful to real people. Like mine is here:

www.redinstead.com.au/allprods.php

 

It would be good to do the same for this one. eg. Many of my sub-categories are the same but with different top categories and so they look as they are doubled up in the list but they are different things.

 

Any chance of somehow combining the two, so that the products listed in allprods come under their correct category/subcategory places? Unfortunately I don't have the php coding skills!

 

You can see the All Categories here:

www.redinstead.com.au/allcategories.php

 

Jen


I haven't lost my mind - I have it backed up on disk somewhere.

Share this post


Link to post
Share on other sites

Hey there, Jen -

 

Great to see ya installed it. Looking over the code change, the only difference I saw was in this section: . "&" . "cPath=" .

 

Looking at one of your sample links:

http://www.redinstead.com.au/default.php?name=Accessories&cPath=59

 

compared to mine (site not live yet):

http://www.mydomain.com/catalog/default.php/name/Product%20Category%20Name/cPath/77

 

Was this your change to compensate for not using Search Engine Safe URLs? The original code does not work without using Safe URLs so I was just curious if this is the method to allow it to work with Safe URLs turned off (or to false). I went with them turned on just because I thought if I'm giving the spider the food, I might as well try get rid of the dynamic URL indicators too. :wink: But hey... I'm just learning the php stuff so I'm all ears if you've got some great info.

 

Oh, and your AllProds page rocks! That a contribution or did you do that mod? I would love to have mine and my AllCategories to have such a great format. If you've got that already, I would think that could be morphed into something for the categories. If it's available, I would love to take a look to see if it's possible.

 

Hope you do find it useful. With my non-osc sites, I find the category pages rank better and I really do think it's because of more alt and title text linking to products that have similar page characteristics. If there are a dozen images with alt="good spider term" it seems that would perform well. I'll keep my fingers crossed, eh!

 

Thanks!

 

-shaun

Share this post


Link to post
Share on other sites

Hey Jen -

 

Yep, that was it... your change seems to be for Search Engine Safe URLs set to 'false'..... so, I tweaked the code and this worked no matter if Search Engine Safe URLs are set to 'true' or 'false'. Anyone want to test to confirm on your system too?

 

This is the entire catalog/allcategories.php file

**NOTE: For those who changed FILENAME_CATEGORIES_INFO to FILENAME_DEFAULT, please make the change in the following code as well.

 

-shaun

 

 

 

<?php

/*

 $Id: allcategories.php,v 1.0 2003/30/04



 osCommerce, Open Source E-Commerce Solutions

 http://www.oscommerce.com



 Copyright (c) 2003 osCommerce

 Copyright (c) 2003 HMCservices



 Released under the GNU General Public License

*/



 require('includes/application_top.php');

 include(DIR_WS_LANGUAGES . $language . '/' . FILENAME_CATEGORIES);



// Set number of columns in listing

define ('NR_COLUMNS', 1);

//

 $breadcrumb->add(HEADING_TITLE, tep_href_link(FILENAME_CATEGORIES, '', 'NONSSL'));

?>

<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">

<html <?php echo HTML_PARAMS; ?>>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">

<?php

// BOF: WebMakers.com Changed: Header Tag Controller v1.0

// Replaced by header_tags.php

if ( file_exists(DIR_WS_INCLUDES . 'header_tags.php') ) {

 require(DIR_WS_INCLUDES . 'header_tags.php');

} else {

?> 

 <title><?php echo TITLE ?></title>

<?php

}

// EOF: WebMakers.com Changed: Header Tag Controller v1.0

?>



<base href="<?php echo (getenv('HTTPS') == 'on' ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>">

<link rel="stylesheet" type="text/css" href="stylesheet.css">

</head>

<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">

<!-- header //-->

<?php require(DIR_WS_INCLUDES . 'header.php'); ?>

<!-- header_eof //-->



<!-- body //-->

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

 <tr>

   <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">

<!-- left_navigation //-->

<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>

<!-- left_navigation_eof //-->

   </table></td>

<!-- body_text //-->

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

     <tr>

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

         <tr>

	 <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>

           <td align="right"></td>

         </tr>

       </table></td>

     </tr>

     <tr>

       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>

     </tr>

     <tr>

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

            <?php	

   $languages_query = tep_db_query("select languages_id, name, code, image, directory from " . TABLE_LANGUAGES . " order by sort_order");

   while ($languages = tep_db_fetch_array($languages_query)) {

   $languages_array[] = array('id' 	 => $languages['languages_id'],

            'name'  => $languages['name'],

                                     'code'  => $languages['code'],

                                     'image'  => $languages['image'],

                                          'directory'	=> $languages['directory']);

   }

           for ($i=0; $i<sizeof($languages_array); $i++) {    

             $this_language_id = $languages_array[$i]['id'];

   $this_language_name = $languages_array[$i]['name'];

   $this_language_code = $languages_array[$i]['code'];

   $this_language_image = $languages_array[$i]['image'];

   $this_language_directory = $languages_array[$i]['directory'];

   echo " <tr>n";

             $categories_query = tep_db_query("SELECT categories_id, categories_name FROM " . TABLE_CATEGORIES_DESCRIPTION . "  WHERE  language_id = $this_language_id ORDER BY categories_name");

   $categories_array = array();

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

      $categories_array[] = array('id'   => $categories['categories_id'],

              'name' => $categories['categories_name']);

   }

   

   for ($j=0; $j<NR_COLUMNS; $j++) {

  	 echo "   <td class=main valign="top">n";

  	 for ($k=$j; $k<sizeof($categories_array); $k+=NR_COLUMNS) {

     $this_categories_id   = $categories_array[$k]['id'];

     $this_categories_name = $categories_array[$k]['name'];

     If (SEARCH_ENGINE_FRIENDLY_URLS == 'false'){

     echo "     <a href="" . tep_href_link(FILENAME_CATEGORIES_INFO, 'name=' .str_replace("/", "/", rawurlencode($this_categories_name)). "&" . "cPath=" . $categories_id . $this_categories_id . (($this_language_code == DEFAULT_LANGUAGE) ? '' : ('&language=' . $this_language_code)), 'NONSSL', false) . "">" . $this_categories_name . "</a>n";

        }

     else {

     echo "     <a href="" . tep_href_link(FILENAME_CATEGORIES_INFO, 'name=' .str_replace("/", "/", rawurlencode($this_categories_name)). "/" . "cPath/" . $categories_id . $this_categories_id . (($this_language_code == DEFAULT_LANGUAGE) ? '' : ('&language=' . $this_language_code)), 'NONSSL', false) . "">" . $this_categories_name . "</a>n";

     }

  	 }

  	 echo "   </td>n";

   }

      echo " </tr>n";

	 }

?>

           </td>

         </tr>

       </table></td>

     </tr>

     <tr>

   <td align="right" class="main"><br><?php echo '<a href="' . tep_href_link(FILENAME_DEFAULT, '', 'NONSSL') . '">' . tep_image_button('button_continue.gif', IMAGE_BUTTON_CONTINUE) . '</a>'; ?></td>

     </tr>

   </table></td>

<!-- body_text_eof //-->

   <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">

<!-- right_navigation //-->

<?php require(DIR_WS_INCLUDES . 'column_right.php'); ?>

<!-- right_navigation_eof //-->

   </table></td>

 </tr>

</table>

<!-- body_eof //-->



<!-- footer //-->

<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>

<!-- footer_eof //-->

</body>

</html>

<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

Share this post


Link to post
Share on other sites
Oh, and your AllProds page rocks! That a contribution or did you do that mod? I would love to have mine and my AllCategories to have such a great format. If you've got that already, I would think that could be morphed into something for the categories. If it's available, I would love to take a look to see if it's possible.

 

I did it with a lot of help from this forum:

http://forums.oscommerce.com/viewtopic.php?t=40584

 

If you can do something to make your All Categories look and work as well then it will be even better. :)

 

I don't like the idea of a hidden link (and from what I hear neither do Google etc) so I would be lots more interested if it could have a purpose for real live people too.

 

 

What change exactly is there in the new code you have posted there? Mine is working fine so I might just leave it. (?)

 

 

Jen


I haven't lost my mind - I have it backed up on disk somewhere.

Share this post


Link to post
Share on other sites

Cool... I'll check out that thread.

 

As for the link to allcategories.php, it's not literally "hidden". Any visitor can (will be able) to hit mine. I just have it in the footer with small font and light-colored text so it's not literally under a hidden tag or anything. Hopefully, I'll be able to dress it up and I'm currently working on working on my code to get it to work with the new Categories Header Tag contribution that is out which should be a marriage made in heaven. :wink:

 

Yes, the version of AllCategories you are using now works fine because you currently have Search Engine Safe URLs turned off which is why you had to change the code. The original version of AllCategories was made for them to be on. The code I just posted simply has an "if" statement to determine if SEARCH_ENGINE_FRIENDLY_URLS is true or false. If true, it uses my original code. If false it uses yours. This way future installs will be good to go either way. :D

 

-shaun

Share this post


Link to post
Share on other sites

I just installed your mod, and I do not understand something.

 

The Safe URLS are non-functional.

 

When I use Safe URLS, it generates a link like so:

 

http://www.sheilastouch.com/oscommerce/cat.../Paper/cPath/24

 

When I click on the link, it is not found as it is not a legal URL.

 

What exactly is the purpose of this link, if it cannot be clicked on?

 

I am quite confused about the usefulness of the mod.

 

I have turned Safe URLs off and the link is legal and works.

 

Thank you

 

Julian Brown

Share this post


Link to post
Share on other sites

Julian-

 

At one time, the contribution only worked with Web-Safe URLs but then we modified it to work both ways. I'm not sure which version of OSC you're using or if this mod will be backwards or forward compatible.

 

I did notice that your All Products contribution is doing the same thing though which leads me to believe it's something outside this contribution. The left column of your All Products doesn't work but the right column does. Something happen there? Might be related. Each half of your product list is running a different format.

 

-shaun

Share this post


Link to post
Share on other sites

I am using MS1.

 

I went to the all products page instead but I had to modify it, can't remember what I modified (it was something simple). If you need some help on it, I can find out what I did.

 

I also put in a mod called Column Product Listing, which I had to modify also, but its pretty cool. It displays the products in a category in 3 columns with pictures instead of a bunch of rows and no pictures.

 

Bodger

Share this post


Link to post
Share on other sites

Hi there!

 

First of all thnx for this work. :)

 

But I have a question (hope you'll understand my english)

 

What do I have to do, when I want the categories only in the language that I'm using at that moment.

What do I have to change?

 

Thnx a lot!

 

Greetings, Martin

Share this post


Link to post
Share on other sites

Hi

 

I have a working version of all categories working on my test site. I also modified it slightly to to include the description of the category. Basically at the moment I have 2 top level (Parent) categories with my products placed in them.

 

What I would like to do is add an image for each category to the listing. Would this be possible? I have tried coding this myself but have had no luck.

 

I would apreciate if somebody could point me in the right direction.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×