Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / creating a link from shopping cart back to main website

creating a link from shopping cart back to main website

Views: 1,514

Results 1 to 13 of 13
18 Aug 2012, 3:27 AM
#1
irori avatar

irori

New Zenner

Join Date:
Jun 2012
Posts:
42
Plugin Contributions:
0

creating a link from shopping cart back to main website

Hello everyone,

I have created a tab called 'back to main website' at the top menu bar of my page. (https://www.ishafairtrade.com.au/zencart) I would like this to link DIRECTLY back to my main website (https://www.ishafairtrade.com) when it is clicked.

I have been told to

'define the constant and create the FILENAME_MAIN_WEBSITE?'

I have no idea how to go about this and would really really appreciate some instructions!

Thankyou!

18 Aug 2012, 9:45 AM
#2
stevesh avatar

stevesh

Black Belt

Join Date:
Feb 2005
Location:
Lansing, Michigan USA
Posts:
19,793
Plugin Contributions:
2

Re: creating a link from shopping cart back to main website

I'm not sure why you would want any kind of define there. Just set the <a href ... to the desired URL.

18 Aug 2012, 1:10 PM
#3
irori avatar

irori

New Zenner

Join Date:
Jun 2012
Posts:
42
Plugin Contributions:
0

Re: creating a link from shopping cart back to main website

stevesh:

I'm not sure why you would want any kind of define there. Just set the <a href ... to the desired URL.

Where exactly do I put this link? Thankyou for your help?

18 Aug 2012, 2:19 PM
#4
keneso avatar

keneso

Totally Zenned

Join Date:
May 2009
Posts:
1,273
Plugin Contributions:
3

Re: creating a link from shopping cart back to main website

In the same file you put this
<a href="http://ishafairtrade.com.au/zencart/index.php?main_page=FILENAME_MAIN_WEBSITE">Main Website</a>

Just do it like this
<a href="http://ishafairtrade.com.au/>Main Website</a>

18 Aug 2012, 2:57 PM
#5
irori avatar

irori

New Zenner

Join Date:
Jun 2012
Posts:
42
Plugin Contributions:
0

Re: creating a link from shopping cart back to main website

keneso:

In the same file you put this
<a href="http://ishafairtrade.com.au/zencart/index.php?main_page=FILENAME_MAIN_WEBSITE">Main Website</a>

Just do it like this
<a href="http://ishafairtrade.com.au/>Main Website</a>

This is what I have on that line

<li><?php echo '<a href="' . zen_href_link(FILENAME_MAIN_WEBSITE) . '">'; ?><?php echo HEADER_TITLE_MAIN_WEBSITE; ?></a> | </li>

where exactly do I put the link into this? as when I tried a few weeks ago my whole cart went blank...

18 Aug 2012, 3:06 PM
#6
keneso avatar

keneso

Totally Zenned

Join Date:
May 2009
Posts:
1,273
Plugin Contributions:
3

Re: creating a link from shopping cart back to main website

Change this

<li><?php echo '<a href="' . zen_href_link(FILENAME_MAIN_WEBSITE) . '">'; ?><?php echo HEADER_TITLE_MAIN_WEBSITE; ?></a> | </li> to <li><a href="http://ishafairtrade.com.au/>Main Website</a> | </li>
19 Aug 2012, 10:29 PM
#7
irori avatar

irori

New Zenner

Join Date:
Jun 2012
Posts:
42
Plugin Contributions:
0

Re: creating a link from shopping cart back to main website

keneso:

Change this

<li><?php echo '<a href="' . zen_href_link(FILENAME_MAIN_WEBSITE) . '">'; ?><?php echo HEADER_TITLE_MAIN_WEBSITE; ?></a> | </li> to <li><a href="http://ishafairtrade.com.au/>Main Website</a> | </li>

This does not work. It basically made the 'log in' tab (normally next to the 'main website' tab) into a link back to the mail website saying 'page not found'. It does not create a 'main website' tab? I am not sure why, when I try and put it in anywhere else in the existing code I loose my whole cart again....

here is the existing code from that area in my tpl_header.php

<!--bof-navigation display--> <div id="navMainWrapper"> <div id="navMain"> <ul class="back"> <li><?php echo '<a href="' . HTTP_SERVER . DIR_WS_CATALOG . '">'; ?><?php echo HEADER_TITLE_CATALOG; ?></a> | </li> <li><?php echo '<a href="' . zen_href_link(FILENAME_MAIN_WEBSITE) . '">'; ?><?php echo HEADER_TITLE_MAIN_WEBSITE; ?></a> | </li> <?php if ($_SESSION['customer_id']) { ?> <li><a href="<?php echo zen_href_link(FILENAME_LOGOFF, '', 'SSL'); ?>"><?php echo HEADER_TITLE_LOGOFF; ?></a> | </li> <li><a href="<?php echo zen_href_link(FILENAME_ACCOUNT, '', 'SSL'); ?>"><?php echo HEADER_TITLE_MY_ACCOUNT; ?></a> | </li> <?php } else { if (STORE_STATUS == '0') { ?> <li><a href="<?php echo zen_href_link(FILENAME_LOGIN, '', 'SSL'); ?>"><?php echo HEADER_TITLE_LOGIN; ?></a> | </li> <?php } } ?> <li><img src="includes/templates/alysa_rounded/images/cart.jpg" class="cart-image" alt="the shopping cart" /><a href="<?php echo zen_href_link(FILENAME_SHOPPING_CART, '', 'NONSSL'); ?>"><?php echo HEADER_TITLE_CART_CONTENTS; ?> - <?php echo $_SESSION['cart']->count_contents();?> item(s) - <?php echo $currencies->format($_SESSION['cart']->show_total());?></a> | </li> <li><a href="<?php echo zen_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'); ?>"><?php echo HEADER_TITLE_CHECKOUT; ?></a></li> <?php if ($_SESSION['cart']->count_contents() != 0) { ?> <?php }?> </ul> </div>
19 Aug 2012, 11:46 PM
#8
keneso avatar

keneso

Totally Zenned

Join Date:
May 2009
Posts:
1,273
Plugin Contributions:
3

Re: creating a link from shopping cart back to main website

Sorry, a typo, I missed closing " after au/
Try this

<li><a href="http://ishafairtrade.com.au/">Main Website</a> | </li>
20 Aug 2012, 12:07 AM
#9
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: creating a link from shopping cart back to main website

If you look in the tpl_header.php in the default template, you will see how the link for the Home page uses:

<?php echo '<a href="' . HTTP_SERVER . DIR_WS_CATALOG . '">'; ?><?php echo HEADER_TITLE_CATALOG; ?></a>

If your link is to go to your address:
http://your_domain_name.com

or in your case .com.au

You really are better using a relative link than a specific link, as it is a good coding habit ...

For your domain, you could use:

<?php echo '<a href="' . HTTP_SERVER . '">'; ?>Main Website</a>

and if you mean for a subdirectory on your server, such as:
/my_fav_directory

such as:
http://your_domain_name.com/my_fav_directory

you could use:

<?php echo '<a href="' . HTTP_SERVER . '/my_fav_directory/' . '">'; ?><?php echo Main Website; ?></a>

and if you mean for the subdirectory that your store is in, and your store is in:
/shop

such as:
http://your_domain_name.com/shop

you could use:

<?php echo '<a href="' . HTTP_SERVER . DIR_WS_CATALOG . '">'; ?><?php echo Main Website; ?></a>

Relative links are always a better idea than hard coded links, as a rule, for secure vs non-secure pages and for moves to root or sub-directories on the same site or moves to other domains ...

20 Aug 2012, 10:48 AM
#10
irori avatar

irori

New Zenner

Join Date:
Jun 2012
Posts:
42
Plugin Contributions:
0

Re: creating a link from shopping cart back to main website

keneso:

Sorry, a typo, I missed closing " after au/
Try this

<li><a href="http://ishafairtrade.com.au/">Main Website</a> | </li>

This works perfect now Thankyou!

20 Aug 2012, 10:52 AM
#11
irori avatar

irori

New Zenner

Join Date:
Jun 2012
Posts:
42
Plugin Contributions:
0

Re: creating a link from shopping cart back to main website

Ajeh:

If you look in the tpl_header.php in the default template, you will see how the link for the Home page uses:

<?php echo '<a href="' . HTTP_SERVER . DIR_WS_CATALOG . '">'; ?><?php echo HEADER_TITLE_CATALOG; ?></a>
> 
> If your link is to go to your address:
> http://your_domain_name.com
> 
> or in your case .com.au
> 
> You really are better using a relative link than a specific link, as it is a good coding habit ...
> 
> For your domain, you could use:
> ```
<?php echo '<a href="' . HTTP_SERVER . '">'; ?>Main Website</a>

Relative links are always a better idea than hard coded links, as a rule, for secure vs non-secure pages and for moves to root or sub-directories on the same site or moves to other domains ...

Thank you for this information! using relative links as you say makes sense and the link works perfect too, I would love to understand though how exactly it is linking back to my main website? I am guessing the HTTP_SERVER is the part that furnishes the information of where to link back to? How does it do this? I understand how Keneso's resolve form of linking works but I don't quite understand how this works!? :blush:

20 Aug 2012, 1:50 PM
#12
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: creating a link from shopping cart back to main website

If you peek at the file:
/includes/configure.php

it knows the information for your site, where HTTP_SERVER is defined to be your domain name ...

In this instance, you know you want to go to your domain and not the secure page, just because you might be on a secure page ...

Had you wanted to maintain that relationship, of switching between secure and non-secure, there is a function for that as well ...

20 Aug 2012, 11:45 PM
#13
irori avatar

irori

New Zenner

Join Date:
Jun 2012
Posts:
42
Plugin Contributions:
0

Re: creating a link from shopping cart back to main website

Ajeh:

If you peek at the file:
/includes/configure.php

it knows the information for your site, where HTTP_SERVER is defined to be your domain name ...

In this instance, you know you want to go to your domain and not the secure page, just because you might be on a secure page ...

Had you wanted to maintain that relationship, of switching between secure and non-secure, there is a function for that as well ...

Thank you again! much appreciated !