Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

How to move category link location ?


mondobongo3

Recommended Posts

I can't figure out how to do that, so I'm asking here, maybe somebody will help me.

What I need is to move some of the categories links out from Categories Box and to have it elsewhere.

I need to have access to that link from STS template.

 

I think that I need to do something like this:

if ($tree[$counter]['path'] == 27) {
     $categories_string .= '';
     // and here somehow to pass the link to that category in a variable that can be accessed from STS template file
     }else{
     $categories_string .= tep_href_link(FILENAME_DEFAULT, $cPath_new) . '">';
}

 

But I am not sure if this is the correct approach.

 

I hope somebody will post a solution. Thank you.

Link to comment
Share on other sites

Yes, that is definitely possible.

 

Define the variables as session values in your application_top.php, similar to $cPath_array which is another variable from the cat box function.

Add the variables to the top part of the function as globals so they are known within the function. These could be multiple single layer variables or an array of variables, whatever you prefer later for accessing from STS.

 

Then work down the way you did in your example ... and fill the session variables.

I always add quotes around the categories_id when I access one directly ... (your 27 in the example).

:-)

Monika

 

addicted to writing code ... can't get enough of databases either, LOL!

 

my toolbox: Textpad - Compare and Merge - phpMyAdmin - WS_FTP - Photoshop - How to search the forum

 

Interactive Media Award July 2007 ~ category E-Commerce

my advice on the forum is for free, PMs where you send me work are considered consultation which I charge for ...

Link to comment
Share on other sites

Yes, that is definitely possible.

 

Define the variables as session values in your application_top.php, similar to $cPath_array which is another variable from the cat box function.

Add the variables to the top part of the function as globals so they are known within the function. These could be multiple single layer variables or an array of variables, whatever you prefer later for accessing from STS.

 

Then work down the way you did in your example ... and fill the session variables.

I always add quotes around the categories_id when I access one directly ... (your 27 in the example).

I looked over aplication_top.php and this is the chunk of code where $cPath_array appears.

But I don't really understand what and how I should change to achieve my goal. Can you write this for me?

Thanks a lot.

// calculate category path
 if (isset($HTTP_GET_VARS['cPath'])) {
   $cPath = $HTTP_GET_VARS['cPath'];
 } elseif (isset($HTTP_GET_VARS['products_id']) && !isset($HTTP_GET_VARS['manufacturers_id'])) {
   $cPath = tep_get_product_path($HTTP_GET_VARS['products_id']);
 } else {
   $cPath = '';
 }

 if (tep_not_null($cPath)) {
   $cPath_array = tep_parse_category_path($cPath);
   $cPath = implode('_', $cPath_array);
   $current_category_id = $cPath_array[(sizeof($cPath_array)-1)];
 } else {
   $current_category_id = 0;
 }

// include the breadcrumb class and start the breadcrumb trail
 require(DIR_WS_CLASSES . 'breadcrumb.php');
 $breadcrumb = new breadcrumb;

 $breadcrumb->add(HEADER_TITLE_TOP, HTTP_SERVER);
 $breadcrumb->add(HEADER_TITLE_CATALOG, tep_href_link(FILENAME_DEFAULT));

// add category names or the manufacturer name to the breadcrumb trail
 if (isset($cPath_array)) {
   for ($i=0, $n=sizeof($cPath_array); $i<$n; $i++) {
     $categories_query = tep_db_query("select categories_name from " . TABLE_CATEGORIES_DESCRIPTION . " where categories_id = '" . (int)$cPath_array[$i] . "' and language_id = '" . (int)$languages_id . "'");
     if (tep_db_num_rows($categories_query) > 0) {
       $categories = tep_db_fetch_array($categories_query);
       $breadcrumb->add($categories['categories_name'], tep_href_link(FILENAME_DEFAULT, 'cPath=' . implode('_', array_slice($cPath_array, 0, ($i+1)))));
     } else {
       break;
     }
   }
 } elseif (isset($HTTP_GET_VARS['manufacturers_id'])) {
   $manufacturers_query = tep_db_query("select manufacturers_name from " . TABLE_MANUFACTURERS . " where manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "'");
   if (tep_db_num_rows($manufacturers_query)) {
     $manufacturers = tep_db_fetch_array($manufacturers_query);
     $breadcrumb->add($manufacturers['manufacturers_name'], tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id']));
   }
 }

Link to comment
Share on other sites

sorry for that, I thought there was code for that in appl top

 

use something like this for each of your new variables:

 

 

if (!tep_session_is_registered('new_variable1')) tep_session_register('new_variable1');

 

 

and in the function, do not forget to add them to the list of globals!

:-)

Monika

 

addicted to writing code ... can't get enough of databases either, LOL!

 

my toolbox: Textpad - Compare and Merge - phpMyAdmin - WS_FTP - Photoshop - How to search the forum

 

Interactive Media Award July 2007 ~ category E-Commerce

my advice on the forum is for free, PMs where you send me work are considered consultation which I charge for ...

Link to comment
Share on other sites

sorry for that, I thought there was code for that in appl top

 

use something like this for each of your new variables:

 

 

if (!tep_session_is_registered('new_variable1')) tep_session_register('new_variable1');

 

 

and in the function, do not forget to add them to the list of globals!

Let me see if I understand corectly:

in application_top.php i must add this: (of course, 'new_variable1' is replaced with my variable)

if (!tep_session_is_registered('new_variable1')) tep_session_register('new_variable1');

and in categories.php I must add that variable here:

function tep_show_category($counter) {
   global $tree, $categories_string, $cPath_array; //here

Then, condition if category_id matches with my target category, its path to be stored in my variable.

 

One thing that I don't understand is that as I could see, in PHP the variables have "$" sign before name, but in this part of code you say to do it wirhout that dollar symbol... if (!tep_session_is_registered('new_variable1')) tep_session_register('new_variable1'); .

 

I'm sorry, I am not a programmer, just trying to put some things together and trying to make them working. Maybe my understanding in programming languages is too poor and I apologize for that. I appreciate a lot that you are taking some time to explain me, but I'm afraid that I'm not yet entirely enlightened.

It looks more complicated then I thought at first sight :(

 

Thanks again.

Link to comment
Share on other sites

that is php syntax ... for a direct call, use $variable, in the register function, you need to use it in quotes without the $ sign, as it's just a parameter for a function. you should read up a bit on php ;-) ...

:-)

Monika

 

addicted to writing code ... can't get enough of databases either, LOL!

 

my toolbox: Textpad - Compare and Merge - phpMyAdmin - WS_FTP - Photoshop - How to search the forum

 

Interactive Media Award July 2007 ~ category E-Commerce

my advice on the forum is for free, PMs where you send me work are considered consultation which I charge for ...

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...