Permalinks Problems pfffffffffff
3 posts by 2 authors in: Forums > CMS Builder: Plugins & Add-ons
Last Post: August 17, 2013 (RSS)
By Maurice - August 12, 2013 - edited: August 12, 2013
Started using the permalinks plugin and caused many problems by many sites we implemented it.
dos any one have a good breadcrumbs script that works with the permalinks plugin?
we used this one
<?
$ul_id='crumbs';
$bc=explode("/",$_SERVER["PHP_SELF"]);
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>';
?>
and the script
<script type="text/javascript">
function hideul(){
$(".postDetails ul").fadeOut();
$(".postDetails ul:first").fadeIn();
$(".postDetails h1:first span").removeClass("unactive").addClass("active");
}
function mutate(name) {
if($(".postDetails h1[name='"+name+"'] span").hasClass("active")){
$(".postDetails ul[name='"+name+"']").fadeOut();
$(".postDetails h1[name='"+name+"'] span").removeClass("active").addClass("unactive");
}else{
$(".postDetails ul[name='"+name+"']").fadeIn();
$(".postDetails h1[name='"+name+"'] span").removeClass("unactive").addClass("active");
}
}
function activateNav(){
if($("nav.mainNav li a[name='<?php echo $category; ?>']")){
$("nav.mainNav li a[name='<?php echo $category; ?>']").addClass("active");
}
}
</script>
But now it starts counting from the admin perspective ( home>cmsb>plugins>title page
Some one got a good en simple solution?
Greetz M
Dropmonkey.nl
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
PHP Programmer - interactivetools.com
By Maurice - August 17, 2013
whaaaaaa got it working
thnx its great.
u r the best Greg ;-)
Dropmonkey.nl