Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

How can i redirect intex.php to an category (index.php?cPath=x)?


nicolasmezac

Recommended Posts

Well

 

I -once- had done this previously... but I forgot how to do this!

 

I remember that in index.php, i had to change a code, i think it was at the red text...

 

Could you help me?

 

<?php

error_reporting(0);

/*

$Id: index.php 1739 2007-12-20 00:52:16Z hpdl $

 

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

 

Copyright © 2003 osCommerce

 

Released under the GNU General Public License

*/

 

require('includes/application_top.php');

 

// the following cPath references come from application_top.php

$category_depth = 'top';

if (isset($cPath) && tep_not_null($cPath)) {

$categories_products_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id = '" . (int)$current_category_id . "'");

$cateqories_products = tep_db_fetch_array($categories_products_query);

if ($cateqories_products['total'] > 0) {

$category_depth = 'products'; // display products

} else {

$category_parent_query = tep_db_query("select count(*) as total from " . TABLE_CATEGORIES . " where parent_id = '" . (int)$current_category_id . "'");

$category_parent = tep_db_fetch_array($category_parent_query);

if ($category_parent['total'] > 0) {

$category_depth = 'nested'; // navigate through the categories

} else {

$category_depth = 'products'; // category has no products, but display the 'no products' message

}

}

}

 

require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_DEFAULT);

?>

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

<html <?php echo HTML_PARAMS; ?>>

<head>

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

 

Link to comment
Share on other sites

You will get stuck in a loop.

 

Assuming you want to just redirect index.php when no cPath is set you could try something like below .

 

$myPath would be the category_id you want to redirect to.

 


//below application_top.php
 if (!isset($cPath) || !tep_not_null($cPath)) {
  $myPath = '5'; // Category id  to go
  tep_redirect(tep_href_link(FILENAME_DEFAULT,'cPath='.$myPath));
 }

 

Backup .. untested..

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...