Login!
Lost password?
 

MODx Bug/Feature Tracker and Feature Requests

Welcome to the MODx CMS Tracker. Please choose the appropriate project from the drop down menu and provide as much information as possible regarding your server environment and browser. Thanks!

FS#116 — Rewrite Weblink URLs

Attached to Project — MODx
Opened by Anonymous Submitter - Friday, 11 November 2005, 02:11PM
Last edited by Ryan Thrash (rthrash) - Saturday, 27 September 2008, 08:07AM
Task Type Feature Request
Category Core Distribution
Status Implementing
Assigned To Garry Nutting (garryn)
Operating System All
Severity Medium
Priority High
Reported Version 0.9.0
Due in Version Undecided
Due Date Undecided
Percent Complete 0%

Details

I've created several Weblink documents and I use NewsListing to display a list of links. All outgoing links are identified as being internal documents (which they are of course).It would be nice to be able to rewrite the URLs so they will display as the actual URL the Weblink is pointing to.
This task depends upon

This task blocks these from closing
Comment by Mark Kaplan (mark2005) - Sunday, 20 November 2005, 12:30AM
Definately needed

Comment by Ryan Thrash (rthrash) - Wednesday, 20 September 2006, 10:29PM
Kyle... isn't this implemented?

Comment by Kyle Jaebker (kylej) - Thursday, 28 September 2006, 10:59AM
I just added this to the wayfinder snippet, I can look into getting this as the default behavior for all of modx. Maybe with some kind of toggle built into the manager also.

Comment by Eugeny (lapot) - Saturday, 10 November 2007, 03:15PM
I needed it also, and I've patched my /manager/includes/document.parser.class.inc.php (0.9.6 version) and it works fine:
============8<=====================
function makeFriendlyURL($pre, $suff, $alias) {
$dir= dirname($alias);
// beginning of patch: if document is of reference type paste it's content in the url
if(preg_match("/^URL:/", $alias)){
return preg_replace("/^URL:(.*)/", "\\1",$alias);
} else return MODX_BASE_URL.($dir != '.' ? "$dir/" : "") . $pre . basename($alias) . $suff;
// end of patch
}

function rewriteUrls($documentSource) {
// rewrite the urls
if ($this->config['friendly_urls'] == 1) {
$aliases= array ();
foreach ($this->aliasListing as $item) {
// beginning of patch: if document is of reference type paste it's value in the url
$tblsc= $this->getFullTableName("site_content");
$sql="SELECT content FROM $tblsc WHERE type='reference' AND id='".$item['id']."'";
$result = $this->dbQuery($sql);
if($this->recordCount($result)==0){// paste defaults:
$aliases[$item['id']]= (strlen($item['path']) > 0 ? $item['path'] . '/' : '') . $item['alias'];
} else {// paste url
$row = $this->fetchRow($result);
$aliases[$item['id']]= "URL:".$row['content'];
}
// end of patch

}
============8<=====================
Also, this code solves the problem of tree-like semantic urls (generated link is absolute /it was relative and caused troubles/, but doesn't contain domain name).

Hope, this helps =)

Comment by Garry Nutting (garryn) - Sunday, 28 September 2008, 08:15AM
Suggested patch doesn't take into account if weblinks point to internal documents therefore it can't be implemented this way. Any other ideas?