Home | Store | osCommerce Tutorials

osCommerce tep_href_link() Function

The osCommerce tep_href_link() function used to join "http://www.YourShopDomain.com/" or "http://YourShopDomain.com/" with the 1st parameter and 2nd parameter.

In other words, tep_href_link(1st parameter, 2nd parameter); is something like:

"http://www.YourShopDomain.com/" + 1st parameter + 2nd parameter

Let's play around tep_href_link() function with some examples.

osCommerce tep_href_link() function example 1:

<?php

require('includes/application_top.php');

$categories_id = "1_17";
$cPath_new = tep_get_path ($categories_id);

echo 'The link is now: ' . tep_href_link (FILENAME_DEFAULT, $cPath_new);

?>

Save the file as tep_href_link_function_1.php.

Upload to the home directory (catalog folder) of osCommerce shop.

Access the URL of this file.

The output of the above typical PHP example should look like:

The link is now: http://www.osc.cz.cc/index.php?cPath=1_17

Explanations:

Let's check the PHP codes line by line.

$categories_id = "1_17";
$cPath_new = tep_get_path ($categories_id);

The $cPath_new variable now has the value of "cPath=1_17". Please see osCommerce tep_get_path() custom function tutorial if you do not know how the answer comes.

echo 'The link is now: ' . tep_href_link (FILENAME_DEFAULT, $cPath_new);

The FILENAME_DEFAULT is usually defined as "index.php" in catalog/includes/filenames.php file.

Here's some of the examples:

Links URL FILENAME_DEFAULT
Hardware http://osc.cz.cc/index.php?cPath=1 index.php
Software http://osc.cz.cc/index.php?cPath=2 index.php
DVD Movies http://osc.cz.cc/index.php?cPath=3 index.php
CDROM Drives http://osc.cz.cc/index.php?cPath=1_17 index.php
Graphics Cards http://osc.cz.cc/index.php?cPath=1_4 index.php
Keyboards http://osc.cz.cc/index.php?cPath=1_8 index.php
Memory http://osc.cz.cc/index.php?cPath=1_16 index.php
Mice http://osc.cz.cc/index.php?cPath=1_9 index.php
Simulation http://osc.cz.cc/index.php?cPath=2_18 index.php
Cartoon http://osc.cz.cc/index.php?cPath=3_13 index.php
Privacy Notice http://osc.cz.cc/privacy.php index.php
Contact Us http://osc.cz.cc/contact_us.php index.php

The tep_href_link (FILENAME_DEFAULT, $cPath_new); function simply join them to-gether as below:

http://www.osc.cz.cc/ + index.php + ? + cPath=1_17

Okay! We have some basic concept of osCommerce tep_href_link() function. Let's play with one more example:

osCommerce tep_href_link() function example 2:

<?php

require('includes/application_top.php');

$categories_id = "1_17";
$cPath_new = tep_get_path ($categories_id);

echo "<a href=" . tep_href_link (FILENAME_DEFAULT, $cPath_new) . ">" . "Click here to access CDROM Drives" . "</a>";

?>

Save the file as tep_href_link_function_2.php.

Upload to the home directory (catalog folder) of osCommerce shop.

Access the URL of this file.

The output of the above typical PHP example should look like:

Click here to access CDROM Drives

When you hove the mouse pointer over the link, it should appear the following in the status bar:

http://osc.cz.cc/index.php?cPath=1_17

I think you should know how the above codes works therefore further explanation will not be required here.

This is the end of osCommerce PHP tep_href_link() function Tutorial