SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Zealot TCJeter's Avatar
    Join Date
    Jun 2002
    Location
    Anchorage, AK
    Posts
    187
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Loading content into a frame according to link

    Hello all,

    I have been reading some of the posts in the tutorials section, but haven't found exactly what I'm looking for. I understand using the POST or GET to pass a variable, but here's what else I need help on.

    Our company sends out newsletters with links to the site for specific special offers (a travel web site). The guy that managed the site before I got a hold of it created a new frames page for every special to be displayed (i.e. - /newsletter_frames_special1_11_03.htm). The (frames) page has a 'main' frame that the third-party information is loaded into. Needless to say, there are hundreds of files on the server.

    I really want to streamline this process with PHP, I just need a little direction. Would I create a 'main' frame template with an array that would provide the specified third-party content based on the variable received?? Is this thinking in the right direction, or would that array eventually grow large enough to slow the load times? I could keep about 15-20 'active' references in the array and delete the old ones after a period of time.

    Any help on getting this running would be greatly appreciated.

    Thanks,
    -TC

  2. #2
    SitePoint Zealot TCJeter's Avatar
    Join Date
    Jun 2002
    Location
    Anchorage, AK
    Posts
    187
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    more....

    I just read through this article and now I'm putting together the page dynamically on the server, rather than use frames - a much better approach.

    But, now I need to know how to load a URL into the 'main' section of the document according to the variable sent in my newsletter links.

    I saw the following code and I'm thinking it has to be something similar I need to do in the parent, target file....right?
    PHP Code:
    <?
    if($redirect == 'holiday_special_1') { 
    header($main == "Location: http://www.offersite.com/?visitor=me&userID=123" ); 

    elseif(
    $redirect == 'holiday_special_2') { 
    header("Location: http://www.offersite.com/?visitor=me&userID=124" ); 
    }
    elseif(
    $redirect == 'holiday_special_3') { 
    header("Location: Location: http://www.offersite.com/?visitor=me&userID=125" ); 

    else { 
    //if someone gets to the page without the referer set/correct where will they go then 
    header("Location: index.html" ); 

    ?>
    ...except I can't use the 'header' function after it's already been written. Am I anywhere close? I need to be able to convert a variable from the link to reflect a URL loaded in to the 'main' section of the dynamically built page...make sense?

    Thanks,
    -TC

  3. #3
    SitePoint Zealot TCJeter's Avatar
    Join Date
    Jun 2002
    Location
    Anchorage, AK
    Posts
    187
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Any input on this??.....anyone.......

  4. #4
    PHP manual bot bronze trophy Gaheris's Avatar
    Join Date
    Oct 2003
    Location
    Germany
    Posts
    2,195
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't know if this is what you want...
    Anyway, as an example if you pass a valid content name, which is an index in the availableContent array it will be included. But if you don't pass one or the passed on one is invalid then a default content page get's included. As I wrote in the comment the availableContent array should be generated out of a database. With this you could easily add a new content page trough a web frontent.

    PHP Code:
    // Available content (should come from a database)
    $a_availableContent = array('holiday_special_1' => 'http://www.offersite.com/?visitor=me&userID=123',
                                
    'holiday_special_2' => 'http://www.offersite.com/?visitor=me&userID=124',
                                
    'holiday_special_3' => 'http://www.offersite.com/?visitor=me&userID=125');
    // The default content
    $s_defaultContent   'http://www.offersite.com/offers/';

    // Assign content
    $s_toInclude = (isset($_GET['offer']) && 
                    
    in_array($_GET['offer'], $a_availableContent)) ? $a_availableContent[$_GET['offer']] 
                                                                   : 
    $s_defaultContent;
    // Include
    require($s_toInclude); 

  5. #5
    SitePoint Zealot TCJeter's Avatar
    Join Date
    Jun 2002
    Location
    Anchorage, AK
    Posts
    187
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Hmmm...

    Gaheris - First of all, thanks for your input. I'm not sure if this will work because I keep getting an error. The third-party content that I'm trying to offer via my 'main' content section includes variables for their site in the URL. So, I get an error stating that 'cookies are not enabled'. But, of course, they are...the variables just aren't being passed.

    About the code you posted - would this array take the 'offer' value (be it holiday_special_1, _2 or _3) and provide the listed URL according to the one chosen? 'Offer' being the variable, that is.

    Thanks,
    -TC

  6. #6
    PHP manual bot bronze trophy Gaheris's Avatar
    Join Date
    Oct 2003
    Location
    Germany
    Posts
    2,195
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The third-party content that I'm trying to offer via my 'main' content section includes variables for their site in the URL. So, I get an error stating that 'cookies are not enabled'.
    Does this error message get included instead of the actual content which should have been available when referenced by this URL?
    One question before we try solving this, have you got permission from the content owner to include his content? Because first, you are taking his content and presenting it as your own and second, you are using his bandweight.

    About the code you posted - would this array take the 'offer' value (be it holiday_special_1, _2 or _3) and provide the listed URL according to the one chosen? 'Offer' being the variable, that is.
    Yes. To call it you would have URLs like http://www.example.com/?offer=holiday_special_1, which would include the correct content.

  7. #7
    SitePoint Zealot TCJeter's Avatar
    Join Date
    Jun 2002
    Location
    Anchorage, AK
    Posts
    187
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    error message

    Gaheris - Yes. Absolutely...we pay good money (a travel company) to have this third party content available for people to book cruises and such online through our account. And yes, it puts this error on the screen when I try to implement it by way of the links provided by this third-party service.

    Thanks,
    -TC

  8. #8
    PHP manual bot bronze trophy Gaheris's Avatar
    Join Date
    Oct 2003
    Location
    Germany
    Posts
    2,195
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Okay, I was pretty sure that you had the permission, but I had to ask. I hope I didn't offend you with that question.

    To your questions. One way would be to do the complete HTTP requests manually (btw. with/without cURL) so that you can react and simulate sent cookies. But that, obviously would be quite a pain (I know what I'm talking about, I did it once).

    As I haven't gotten any other ideas at the moment I will let some other people voice their opinions.

  9. #9
    SitePoint Zealot TCJeter's Avatar
    Join Date
    Jun 2002
    Location
    Anchorage, AK
    Posts
    187
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No worries. The site I'm working on was basically a third-party engine. It's just top and left frames that provide links to all of these vendors; the way it was set up, there is a new frames page for every stinkin' offer that comes along. Too much duplication and too many files similarly named - not my doing.

    So, now I'm try ing to find a way to build them 'on the fly' so we can pare down the files.

    Thanks,
    -TC


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •