Nov 20, 2008, 05:38 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
Search via SMF or Google: modx forums all of modxcms.com web
  MODxCMS.com   Forums   Help Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: Different exteniosn with friendly URLS?  (Read 2691 times)
0 Members and 1 Guest are viewing this topic.
Briggsy
Sr. Member
****
Posts: 372



WWW
« on: Dec 30, 2005, 05:11 AM »

Is there any one to change the extension of a single link when using friendly URLS and add extensins?

I have one link I want to end in XML. I tried to give it an alias of .XML but it added .HTML to the end of it so it now reads DOCUMENT.XML.HTML

Logged

Emergency Management Academy of New Zealand
      http://www.emanz.ac.nz

MODx Sandbox   Login: sandbox  Password: castle

Admin Sandbox   Login: sandbox  Password: castle
xwisdom
Foundation
*
Posts: 1,732



« Reply #1 on: Dec 30, 2005, 11:01 AM »

Here's a quick fix for $modx->makeUrl to not appy .html suffix to aliases with an extension (e.g. .xml, .pdf, etc)

I have not tested it but I think it should work.

Code:
function makeUrl($id, $alias='', $args='') {
$url= '';
$virtualDir= '';
if(!is_numeric($id)) {
$this->messageQuit('`'.$id.'` is not numeric and may not be passed to makeUrl()');
}
if($args!='' && $this->config['friendly_urls']==1) {
// add ? to $args if missing
$c = substr($args,0,1);
if ($c=='&') $args = '?'.substr($args,1);
elseif ($c!='?') $args = '?'.$args;
}
elseif($args!='') {
// add & to $args if missing
$c = substr($args,0,1);
if ($c=='?') $args = '&'.substr($args,1);
elseif ($c!='&') $args = '&'.$args;
}
if($this->config['friendly_urls']==1) {
if($alias!='') {
$url= $this->config['friendly_url_prefix'].$alias;
} elseif($alias=='') {
$alias = $id;
if($this->config['friendly_alias_urls']==1) {
$al = $this->aliasListing[$id];
$alPath = !empty($al['path'])? $al['path'] . '/': '';
if($al && $al['alias']) $alias = $al['alias'];
}
$alias = $alPath . $this->config['friendly_url_prefix'].$alias.$suffix;
$url = $alias;
}
$pa = pathinfo($url); // get path info array
$suffix = !empty($pa[extension]) ? '':$this->config['friendly_url_suffix'];
$url.= $suffix.$args; // apply suffix and arguments
}
else {
$url= 'index.php?id='.$id.$args;
}
return $this->config['base_url'] . $virtualDir . $url;
}
Logged

xWisdom
www.xwisdomhtml.com
The fear of the Lord is the beginning of wisdom:
MODx Co-Founder - Create and do more with less.
Briggsy
Sr. Member
****
Posts: 372



WWW
« Reply #2 on: Dec 30, 2005, 04:36 PM »

I replaced the original code in document.parser.class.inc.php with the one above, but it doesn't seem to work. Still appending .html

Any other ideas as this is way over my head?

[EDIT] When I compare what was in the original file and the code above, they are the same.... did you cut n paste the wrong bit?
« Last Edit: Dec 30, 2005, 05:05 PM by briggsys » Logged

Emergency Management Academy of New Zealand
      http://www.emanz.ac.nz

MODx Sandbox   Login: sandbox  Password: castle

Admin Sandbox   Login: sandbox  Password: castle
xwisdom
Foundation
*
Posts: 1,732



« Reply #3 on: Jan 01, 2006, 10:32 AM »

Hmmm,

That's odd they can't be the same.

See here:

Code:
if($this->config['friendly_urls']==1) {
if($alias!='') {
$url= $this->config['friendly_url_prefix'].$alias;
} elseif($alias=='') {
$alias = $id;
if($this->config['friendly_alias_urls']==1) {
$al = $this->aliasListing[$id];
$alPath = !empty($al['path'])? $al['path'] . '/': '';
if($al && $al['alias']) $alias = $al['alias'];
}
$alias = $alPath . $this->config['friendly_url_prefix'].$alias.$suffix;
$url = $alias;
}
$pa = pathinfo($url); // get path info array
$suffix = !empty($pa[extension]) ? '':$this->config['friendly_url_suffix'];
$url.= $suffix.$args; // apply suffix and arguments
}
else {
$url= 'index.php?id='.$id.$args;
}
Logged

xWisdom
www.xwisdomhtml.com
The fear of the Lord is the beginning of wisdom:
MODx Co-Founder - Create and do more with less.
Briggsy
Sr. Member
****
Posts: 372



WWW
« Reply #4 on: Jan 01, 2006, 04:32 PM »

Must have screwed up my copy and paste as I used Winmerge to compare files and it said they were the same. However re done it with my own eyes, and yup they are different... sorry  Smiley

This however didn't seem to make a difference, the link still has .html appended, so it now has rssfeed.xml.html even though the alias in rssfeed.xml. If I change the alias it, the new one still has .html appended

If I type in the url http://www.emanz.ac.nz/rssfeed.xml, I get the document, I also get it if I add .html to that.
Logged

Emergency Management Academy of New Zealand
      http://www.emanz.ac.nz

MODx Sandbox   Login: sandbox  Password: castle

Admin Sandbox   Login: sandbox  Password: castle
eastbind
Sr. Member
****
Posts: 253


This ideograph means LOVE! I love MODx.


WWW
« Reply #5 on: Jan 18, 2006, 08:00 AM »

I have troubled with the same problem, too.
I show my solution.

As well as the mod mentioned above, I add the followings.

in document.parser.class.inc.php
Code:
function makeFriendlyURL($pre,$suff,$alias) {
// Modified for .xml extension 2006/1/18
$dir = dirname($alias);
$painfo = pathinfo($alias);
$tmpsuffix = !empty($painfo[extension]) ? '':$suff;
return ($dir!='.' ? "$dir/":"").$pre.basename($alias).$tmpsuffix;
// return ($dir!='.' ? "$dir/":"").$pre.basename($alias).$suff;
}
And, for Export, in export_site.static.action.php
Code:
// $filename = !empty($alias) ? $prefix.$alias.$suffix : $prefix.$id.$suffix ;
if(empty($alias)) {
$filename = $prefix.$id.$suffix;
}
else {
$painfo = pathinfo($alias);
$tmpsuffix = !empty($painfo[extension]) ? '':$suffix;
$filename = $prefix.$alias.$tmpsuffix;
}

It seems to be working properly. Wink
Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP

Copyright © 2005-2008 MODxCMS, All rights reserved. Contact Us
Styles by ziworks.com

Powered by SMF 1.1.4 | SMF © 2005, Simple Machines LLC

Valid XHTML 1.0! Valid CSS!