Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

php variable in product url


MrParkle

Recommended Posts

I need help. I'm trying to add another php variable like $maxsubid into the product url.

 

I know this has something to do with this code in product_info.php (approx line 197):

 

<td class="main"><?php echo sprintf(TEXT_MORE_INFORMATION, tep_href_link(FILENAME_REDIRECT, 'action=url&goto=' . $product_info['products_url'], 'NONSSL', true, false ));?></td>

 

but with everything I try I either get a link with the variable name, or I get a link with the variable value - but it redirects to the main page.

 

Additional info: $maxsubid is a global variable. The script recognizes the value. So I do not need help in registering this var.

 

A suggestion, a solution, ... all is more than welcome.

 

Thank you

Link to comment
Share on other sites

I need help. I'm trying to add another php variable like $maxsubid into the product url.

 

I know this has something to do with this code in product_info.php (approx line 197):

 

<td class="main"><?php echo sprintf(TEXT_MORE_INFORMATION, tep_href_link(FILENAME_REDIRECT, 'action=url&goto=' . $product_info['products_url'], 'NONSSL', true, false ));?></td>

 

but with everything I try I either get a link with the variable name, or I get a link with the variable value - but it redirects to the main page.

 

Additional info: $maxsubid is a global variable. The script recognizes the value. So I do not need help in registering this var.

 

A suggestion, a solution, ... all is more than welcome.

 

Thank you

 

The url redirect code in catalog/redirect.php does not accept parameters. You would have to rewrite the code adding the ability to deal with added querystring parameters

Link to comment
Share on other sites

The url redirect code in catalog/redirect.php does not accept parameters. You would have to rewrite the code adding the ability to deal with added querystring parameters

 

I was afraid of this. It is beyond my knowledge, unfortunately. Is there a way to put an url in the product description screen with this parameter?

Link to comment
Share on other sites

I was afraid of this. It is beyond my knowledge, unfortunately. Is there a way to put an url in the product description screen with this parameter?

 

I'm not sure I understand what it is you are attempting to do.

 

Looks like you want a link that redirects OFFSITE to perhaps the product manufacturer including a get variable called maxsubid.

Link to comment
Share on other sites

I'm not sure I understand what it is you are attempting to do.

 

Looks like you want a link that redirects OFFSITE to perhaps the product manufacturer including a get variable called maxsubid.

 

Correct. The variable maxsubid is the customers ID; this way I can use their id on the product page.

Link to comment
Share on other sites

Correct. The variable maxsubid is the customers ID; this way I can use their id on the product page.

 

Well try the following: -

 

catalog/redirect.php

 

Find ..

 

		if (tep_db_num_rows($check_query)) {
	  tep_redirect('http://' . $HTTP_GET_VARS['goto']);
	}

 

Replace with ..

 

		if (tep_db_num_rows($check_query)) {
	  if(isset($HTTP_GET_VARS['maxsubid']) && tep_not_null($HTTP_GET_VARS['maxsubid'])) {
		( false === strpos($HTTP_GET_VARS['goto'], '?') ? $seperator = '?' : $seperator = '&');
		$url = $HTTP_GET_VARS['goto'] . $seperator . 'maxsubid=' . tep_sanitize_string($HTTP_GET_VARS['maxsubid']);
		tep_redirect('http://' . $url);  
	  } else {
	  tep_redirect('http://' . $HTTP_GET_VARS['goto']);
	  }
	}

Link to comment
Share on other sites

In case you copied the first one I changed it.

Link to comment
Share on other sites

		if (tep_db_num_rows($check_query)) {
	  if(isset($HTTP_GET_VARS['maxsubid']) && is_numeric($HTTP_GET_VARS['maxsubid'])) {
		( false === strpos($HTTP_GET_VARS['goto'], '?') ? $seperator = '?' : $seperator = '&');
		$url = $HTTP_GET_VARS['goto'] . $seperator . 'maxsubid=' . (int)$HTTP_GET_VARS['maxsubid'];
		tep_redirect('http://' . $url);  
	  } else {
	  tep_redirect('http://' . $HTTP_GET_VARS['goto']);
	  }
	}

 

A little change for security purposes

Link to comment
Share on other sites

In product_info the code would look something like (Where $customers_id is the variable)

 

<td class="main"><?php echo sprintf(TEXT_MORE_INFORMATION, tep_href_link(FILENAME_REDIRECT, 'action=url&goto=' . $product_info['products_url'] . '&maxsubid=' . (int)$customers_id, 'NONSSL', true, false ));?></td>

Link to comment
Share on other sites

Further .. if $maxsubid is indeed a globally available variable you could ignore other file changes and just change the redirect.php file like ..

 

		global $maxsubid;
	if (tep_db_num_rows($check_query)) {
	  if(isset($maxsubid) && is_numeric($maxsubid)) {
		( false === strpos($HTTP_GET_VARS['goto'], '?') ? $seperator = '?' : $seperator = '&');
		$url = $HTTP_GET_VARS['goto'] . $seperator . 'maxsubid=' . (int)$maxsubid;
		tep_redirect('http://' . $url);  
	  } else {
	  tep_redirect('http://' . $HTTP_GET_VARS['goto']);
	  }
	}

 

This code assumes that $maxsubid is an integer btw.

Link to comment
Share on other sites

This is beginning to work... Just one more question: The url has also fixed parameters so basically I do not need a new '?', only the '&' - What exactly have I got to change in the code for this?

 

PS: Thank you very much for your help so far!

 

The code checks if the ? already exists and if it does it uses & automatically.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...