Forums / Cotonti / Support / Tags and url Rewrite Problem

Pagelinking not correct

GHengeveld
#23777 2010-03-26 06:19
That will likely work, but it's a hack. Next time you upgrade Cotonti you'll have to make this modification again.

What you should do is:
- Open datas/urltrans.dat and add this line at the top
page	*	{page_url_structure()}
- Open/create system/functions.custom.php and add this:
function page_url_structure(&$args, &$spec)
{
    global $sed_cat, $pag, $row, $rpagecat;
 
    $page_cat = (!empty($sed_cat[$rpagecat]['path']) && empty($page_cat)) ? $sed_cat[$rpagecat]['path'] : $page_cat;
    $page_cat = (!empty($sed_cat[$pag['page_cat']]['path']) && empty($page_cat)) ? $sed_cat[$pag['page_cat']]['path'] : $page_cat;
    $page_cat = (!empty($sed_cat[$row['page_cat']]['path']) && empty($page_cat)) ? $sed_cat[$row['page_cat']]['path'] : $page_cat;
    $url =  str_replace('.', '/', $page_cat).'/';    
    if($args['id'])
    {
        $url .= $args['id'];
        unset($args['id']);
    }
    else
    {
        $url .= urlencode($args['al']);
        unset($args['al']);
    }
    return $url;
}
- Then open .htaccess and add this:
RewriteEngine On
#for page id
RewriteRule ^(articles|news)/([a-z-]+)/([a-z-]+)/([a0-9]+)$ page.php?id=$4 [QSA,NC,NE,L]
RewriteRule ^(articles|news)/([a-z-]+)/([0-9]+)$ page.php?id=$3 [QSA,NC,NE,L]
RewriteRule ^(articles|news)/([0-9]+)$ page.php?id=$2 [QSA,NC,NE,L]

#for page alias
RewriteRule ^(articles|news)/([a-z-]+)/([a-z-]+)/([a-zA-Z0-9-_]+)$ page.php?al=$4 [QSA,NC,NE,L]
RewriteRule ^(articles|news)/([a-z-]+)/([a-zA-Z0-9-_]+)$ page.php?al=$3 [QSA,NC,NE,L]
RewriteRule ^(articles|news)/([a-zA-Z0-9-_]+)$ page.php?al=$2 [QSA,NC,NE,L]