add parameter to all URLs

This is a discussion on add parameter to all URLs within the alt.comp.lang.php forums, part of the PHP Programming Forums category; I am trying to make something similar to citysearch.com. For example: If you search for a city, say Raleigh, ...


Go Back   Usenet Forums > PHP Programming Forums > alt.comp.lang.php

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 12-14-2004
Doug
 
Posts: n/a
Default add parameter to all URLs



I am trying to make something similar to citysearch.com. For example:

If you search for a city, say Raleigh, NC, it will find it for you,
but then all other URLs on the page will have the location parameter
attached. For example, say "city=raleigh" So, if you go back to the
home page, or any other page on the site, that will still be attached to
the URL. Is there any easy way to do that? I know PHP has a way to
automatically attach a session ID to every URL.

Is there a way I can attach a parameter of my own choosing automatically?

I don't think cookies will work in this situation. The problem with
cookies is that there is only one cookie with one location in it, where
the user may have several pages open for different locations.

what do you think?
Reply With Quote
  #2 (permalink)  
Old 12-14-2004
Anthony Plunkett
 
Posts: n/a
Default Re: add parameter to all URLs

Doug wrote:
>
>
> I am trying to make something similar to citysearch.com. For example:
>
> If you search for a city, say Raleigh, NC, it will find it for you,
> but then all other URLs on the page will have the location parameter
> attached. For example, say "city=raleigh" So, if you go back to the
> home page, or any other page on the site, that will still be attached to
> the URL. Is there any easy way to do that? I know PHP has a way to
> automatically attach a session ID to every URL.
>
> Is there a way I can attach a parameter of my own choosing automatically?
>
> I don't think cookies will work in this situation. The problem with
> cookies is that there is only one cookie with one location in it, where
> the user may have several pages open for different locations.
>
> what do you think?



Just a quick solution, write a little function like so:

<?php

function appendit() {
if(isset($_GET)) {
$message = '?';
foreach($_GET as $append_key => $append_val ) {
$message .= $append_key.'='.$append_val.'&';
}
}
return $message;
}


$urladdon = appendit();

echo '<a href="test.php'.$urladdon.'">Test Page</a>";
?>

Something like that should do the trick, there might be more automated
ways about, let the group know your findings.

Hope that helps,

Anthony.
Reply With Quote
  #3 (permalink)  
Old 12-15-2004
Chung Leong
 
Posts: n/a
Default Re: add parameter to all URLs

"Doug" <dougd99@XXXXremovetheXearthlink.net> wrote in message
news:lxDvd.3634$2J2.1035@newsread2.news.atl.earthl ink.net...
>
>
> I am trying to make something similar to citysearch.com. For example:
>
> If you search for a city, say Raleigh, NC, it will find it for you,
> but then all other URLs on the page will have the location parameter
> attached. For example, say "city=raleigh" So, if you go back to the
> home page, or any other page on the site, that will still be attached to
> the URL. Is there any easy way to do that? I know PHP has a way to
> automatically attach a session ID to every URL.
>
> Is there a way I can attach a parameter of my own choosing automatically?
>
> I don't think cookies will work in this situation. The problem with
> cookies is that there is only one cookie with one location in it, where
> the user may have several pages open for different locations.
>
> what do you think?


Go way to do this is to turn on output buffering then attach the parameters
to every hyperlink with help from regular expression. A manual search and
replace is probably best though--and probably quicker.


Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 11:30 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0