PHP styleswitch links to return curent url

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
bennieblanco
Forum Newbie
Posts: 1
Joined: Fri Jun 06, 2008 7:50 pm

PHP styleswitch links to return curent url

Post by bennieblanco »

Hello ,
I am trying to edit the styleswitch code to return curent url instead sending users back to index.php (using joomla)

this is what I have

Code: Select all

function getCurrentURL(){
    $cururl = mosGetParam( $_SERVER, 'REQUEST_URI', '' );
    if(($pos = strpos($cururl, "index.php"))!== false){
        $cururl = substr($cururl,$pos);
    }
    $cururl =  sefRelToAbs($cururl);
    $cururl =  ampReplace($cururl);
    return $cururl;
}
 
// COLOR SWITCHER LINKS
while(list($key, $val) = each($mystyles)){
 echo "<a href='".getCurrentURL()."?change_css=".$key."' >".$val["label"]."</a>";
}
 
 
It works but the problem is that the url link keeps on continuing every time you click on the style switch



example :

index.php?option=com_content&task=view&id=24&Itemid=44?change_css=green?change_css=green

I need it to show url only once like

index.php?option=com_content&task=view&id=24&Itemid=44?change_css=green

Thank you


best regards

this was original code , I just split it in 2 files

http://www.finalwebsites.com/snippets.php?id=31
halhead
Forum Newbie
Posts: 1
Joined: Sun Jul 13, 2008 3:25 am

Re: PHP styleswitch links to return curent url

Post by halhead »

Preety good PHP style switcher at this address http://www.nightingalei.derby.sch.uk

Think it uses cookies.
Post Reply