If this is your first visit, check our documentation. To post, register or login.
Forums / Templates, Stylesheets, Page Layout / Different Header based on landing page...one database

Different Header based on landing page...one database

Locked

Started by forced on 21 Nov 2007, 5:18 PM · Views: 2,964

Results 1 to 10 of 10
This thread is locked. New replies are disabled.
21 Nov 2007, 5:18 PM
#1
forced avatar

forced

New Zenner

Join Date:
Oct 2007
Posts:
61
Plugin Contributions:
0

Different Header based on landing page...one database

Hi All...before I dive in with ZC, I want to see if this is possible.

I have a domain name lets call http://www.somesalesite.com

I advertise in many publications. I put in the ads a different "landing" page, such as somesalesite.com/pub1, somesalesite.com/charity1

Is there a way that I can have the corresponding header (pub1 or charity1) show throught the user's session? All the products are the same.

Something like you go to somesalesite.com/pub1. It stores the pub1 as a variable and then redirects to the home page with the header based on the variable?

I see that there is a multiple store addon, but the stores are not really different. plus I don't want to have 20 different domain names.

Thanks for any help in advance! :thumbsup:
-steve

10 Dec 2007, 7:17 PM
#3
forced avatar

forced

New Zenner

Join Date:
Oct 2007
Posts:
61
Plugin Contributions:
0

Re: Different Header based on landing page...one database

using session_start() or zen_session_start() outside of the zencart.

Hi all, I asked a similar question before when I first started out, but now that I am more familiar with ZC and sessions, I want to ask again. First off, here is a link to my shop:http://www.energetixjewelry.com/shop

We do fund raisers with different charities, lets say, for example, and Autism charity. A certain amount of the proceeds go to the charity. So we would advertise the domain of: http://www.energetixjewelry.com/aut From there I would like to store a session variable that will remain after the page is forwarded to the shop url.http://www.energetixjewelry.com/shop

what I have now is an index page in the /aut/ directory. on the page I have:

if (!isset($_SESSION)) {
session_start(); // This connects to the existing session 
session_register ("landing"); // Create a session variable called name 
$_SESSION['landing'] = 'aut';

then i use a php header location to redirect to the main shop url. now my problem is calling that variable on the main page. I want to be able to switch the header image based on what page the user first entered at.

Any ideas?

10 Dec 2007, 9:35 PM
#4
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Re: Different Header based on landing page...one database

forced:

A certain amount of the proceeds go to the charity.How are you doing this part?

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

10 Dec 2007, 9:59 PM
#5
forced avatar

forced

New Zenner

Join Date:
Oct 2007
Posts:
61
Plugin Contributions:
0

Re: Different Header based on landing page...one database

DrByte:

How are you doing this part?

Depends on the charity, but we will use coupon codes to keep track of the sales... I am not totally familiar with the admin process of that part. I am only the web designer...

10 Dec 2007, 10:02 PM
#6
forced avatar

forced

New Zenner

Join Date:
Oct 2007
Posts:
61
Plugin Contributions:
0

Re: Different Header based on landing page...one database

If i use this code on a test page to display the landing value it works fine.... but when I tried putting in on the index.php page of zen... I got an error: Fatal error: Call to a member function add_current_page() on a non-object in D:\Inetpub\energetixjewelry\shop\includes\autoload_func.php on line 90

if (!isset($_SESSION)) {
  session_start();
}
11 Dec 2007, 9:46 PM
#7
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Re: Different Header based on landing page...one database

So, you said you want anyone going to the /aut/ folder to be auto-redirected to the /shop/ folder and know where it came from?

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

11 Dec 2007, 10:10 PM
#8
forced avatar

forced

New Zenner

Join Date:
Oct 2007
Posts:
61
Plugin Contributions:
0

Re: Different Header based on landing page...one database

DrByte:

So, you said you want anyone going to the /aut/ folder to be auto-redirected to the /shop/ folder and know where it came from?
Yes... so that I can use a different header image depending on where they first came in from.

11 Dec 2007, 11:30 PM
#9
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Re: Different Header based on landing page...one database

How about something like this:

  1. /aut/index.php```
    header("HTTP/1.1 301 Moved Permanently");
    header("Location: ../shop/index.php?main_page=index&ref=aut");
And, of course ref=aut could be ref=unitedway or whatever you plan to use later in your code.
In step 3 you'll see that this is also used as an auto-redeem coupon code by setting the 'cc_id' session variable. 

2. /shop/includes/auto_loaders/config.referral_tracking.php```
<?php
/**
 * @package initSystem
 * @copyright Copyright 2003-2007 Zen Cart Development Team
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: config.referral_tracking.php 2006-03-06 drbyte $
 */
  $auto Load Config[100][] = array('autoType'=>'init_script',
                                 'loadFile'=> 'init_referral_tracking.php');
?>

(remove the spaces in auto Load Config before saving)

  1. /shop/includes/init_includes/init_referral_tracking.php```
<?php /** * initialize referral-tracking-system variables * Determines which referral code the customer came in on * * @package initSystem * @copyright Copyright 2003-2007 Zen Cart Development Team * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0 * @version $Id: init_referral_tracking.php 2006-03-06 drbyte $ */ // Determine which 'ref' code was used if (isset($_GET['ref']) && $_GET['ref'] != '') { // Set the 'referral_code' session variable for reference later $_SESSION['referral_code'] = $_GET['ref']; // Use the ref code and set it to be the redeemed coupon code (add // before next line to disable this option) $_SESSION['cc_id'] = $_GET['ref']; } ?>

4. In your template, call the appropriate header image based on whatever $_SESSION['referral_code'] contains.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

12 Dec 2007, 6:20 PM
#10
forced avatar

forced

New Zenner

Join Date:
Oct 2007
Posts:
61
Plugin Contributions:
0

Re: Different Header based on landing page...one database

:clap::clap: You are the man! Can we give hugs on this board? :hug:

Seems to be working like a champ.

I used the following code to create the variable for the image:

if ($_SESSION['referral_code'] != '') {
	$MY_HEADER_LOGO_IMAGE = $_SESSION['referral_code'];
		} else {
		$MY_HEADER_LOGO_IMAGE = 'header'; 
		}

I used the following code for the header image:

echo '<a href="' . HTTP_SERVER . DIR_WS_CATALOG . '">' . '<img src="https://www4027.ssldomain.com/energetixjewelry/shop/includes/templates/energetix/images/' . $MY_HEADER_LOGO_IMAGE. '.gif"' . '</a>'; 

Is there more of a zen way, other than putting the full image URL?