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
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 |
|
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
============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 =)