Форуми / Cotonti / Support / Tags and url Rewrite Problem

Pagelinking not correct

scriptor
#1 24.03.2010 04:55
When URL Rewrites on the Tag System Links to a Page are not correct.
For Example:
tags show this
yoursite.com/artikel.html

and it would be that
yoursite.com/category/artikel.html

Anyone an idea how to fix it?
[url=http://www.freak-forum.de]Freak-Forum.de[/url] - The Freakstyle Community<br />
[url=http://www.adelmann-solutions.com]adelmann-solutions, webdesign Freiburg[/url]
Trustmaster
#2 24.03.2010 05:05
What rewrite rules do you use for it?
May the Source be with you!
scriptor
#3 24.03.2010 05:12
i use for an example the URL Transformation Rules for pages
example:
Area: Page
Parameters: al=*
Format: {$c}/{$al}.html

Added 1 day later:

I solve the problem in the tag plugin file functions.php line 145 i change this

From: 'TAGS_RESULT_ROW_URL' => empty($row['page_alias']) ? sed_url('page', 'id='.$row['page_id']) : sed_url('page', 'al='.$row['page_alias']),
TO: 'TAGS_RESULT_ROW_URL' => $row['page_alias'] ? $row['page_cat'].'/'.$row['page_alias'].'.html' : sed_url('page', 'al='.$row['page_alias']),
[url=http://www.freak-forum.de]Freak-Forum.de[/url] - The Freakstyle Community<br />
[url=http://www.adelmann-solutions.com]adelmann-solutions, webdesign Freiburg[/url]

Відредаговано: scriptor (25.03.2010 18:08, 14 років тому)
GHengeveld
#4 26.03.2010 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]
donP
#5 26.03.2010 18:48
UrlRewriting requires hack in many core files indeed... for example, I had to replace
header("Location: " . SED_ABSOLUTE_URL . $r_url);
with
header("Location: " . $r_url);
in page.add.inc.php
and oher similiar lines in page.edit.inc.php 'cause using rewriting like me (to create fake third level domains with main category code of page structure) is incompatible with SED_ABSOLUTE_URL...

In those locations we must consider to force the core to control if the actual rewritten url (by sed_url() + functions.custom) it's a compatible-old one or it already contains http:// or a third level domain format...
in [color=#729FCF][b]BLUES[/b][/color] I trust
GHengeveld
#6 27.03.2010 07:44
header("Location: ".sed_url(...)) is bad practice and should be replaced with sed_redirect(sed_url(...))
donP
#7 27.03.2010 15:58
Core files are full of header("Location: "...) :O
in [color=#729FCF][b]BLUES[/b][/color] I trust
GHengeveld
#8 27.03.2010 23:07
Yes, I know. sed_redirect is actually the same as header Location, but it allows for a fallback to <meta refresh> in case header Location is unsupported for some reason.
In the core (and plugins), all URLs should be created using sed_url(), since this allows for the automated rewriting with urltrans.dat. Absolute URLs may prevent this from working correctly with dynamic subdomains (since it prepends the base domain as set in the configuration panel, which usually contains www as subdomain).
MUST!
#9 03.04.2010 19:45
You can show the page title as the URL instead of the alias?