Permalinks Problems pfffffffffff

By gregThomas - August 12, 2013

Hi Maurice, 

The reason this happens is that if you set the permalink directory as /test/, this directory doesn't exist on the server, but the correct page is retrieved by the permanlinks system, which is were PHP_SELF will be set to when the page loads. To get around this you could use the same method that the permalink plugin uses to retrieve the file path from the URL:

  $_REDIRECT_URL = (@$REDIRECT_URL)? $REDIRECT_URL : coalesce(@$_SERVER['REDIRECT_URL'], @$_SERVER['SCRIPT_URL'], array_first(explode('?',$_SERVER['REQUEST_URI'])));

So the above code works by checking if the the REDIRECT_URL variable exists (which is created by the permalinks plugin), if it does it's used, otherwise the first variable that exists from $_SERVER['REDIRECT_URL'], $_SERVER['SCRIPT_URL'], $_SERVER['REQUEST_URI'] is used.

Then you can use the redirect URL variable in script:

<?php
  $ul_id='crumbs';
  $bc=explode("/",$REDIRECT_URL);
  echo '<a href="/">HOME</a>';
  $brcount =0;$link='http://domainname.com'; 
  foreach($bc as $key=>$value){
    if($value != '' && isset($bc[$brcount++])){
      $link.='/'.$value;
      echo '<a href="'.$link.'" alt="'.ucfirst($value).'">'.strtoupper($value).'</a>';
    }
    $brcount++;
  }

  echo '<span>'.$pagetitle.'</span>';
?>

Let me know if you have any questions

Cheers!

Greg

Greg Thomas







PHP Programmer - interactivetools.com

By Maurice - August 17, 2013

whaaaaaa got it working

thnx its great.

u r the best Greg ;-)

-------------------------------------------

Dropmonkey.nl