#1 January 28, 2015 2:14pm

jmason03
Member
Registered: January 9, 2014
Posts: 123

Appending / on links to files

I'm running 4.1.3 and I can't tell if what I'm experiencing is a bug based on my setup or a bug in the core of BigTree. What is happening is that when a user puts in a link to a file (such as a pdf) and click "Save and Publish" that link has a / added to the end of it which screws up the link because the browser thinks the filename is a directory and throws a 404 error. I do know that once processed, these links, that are entered by users, are being converted to IPLs and when I display them on the page I am calling getInternalPageLink and I think that the issue is in that function somewhere. I think that either in the IPLCache or in the returned value a trailing / is added that breaks links to files. I'm definitely not sure if that's where the issue is, I narrowed it down a little but haven't yet found exactly where it's happening. I thought I would check with you to see if this has ever come up as an issue. If not I'll assume it's an issue I caused somewhere in my setup.

Thanks

Offline

#2 January 28, 2015 4:56pm

timbuckingham
Administrator
From: Baltimore, MD
Registered: April 2, 2012
Posts: 970

Re: Appending / on links to files

If they're being converted to IPLs, it sounds like the files might reside in a directory below a BigTree "page". This shouldn't normally occur because BigTree page routes can't be created that equate to a directory. For instance, if you have a directory at /site/files/ and create a page at your page root called "Files" its route will be "files-2/".

My best guess is that a page was created first and then a directory was created. When BigTree does it's internal page link encoding it sees the page and thinks your file is a route appended to the page. The links to files *should* be encoded as {staticroot}files/whatever-file.pdf, not ipl://.

If my hunch is correct, BigTree should probably check to see if it's a file path before jumping to ipl:// encoding.

Offline

#3 January 28, 2015 5:42pm

jmason03
Member
Registered: January 9, 2014
Posts: 123

Re: Appending / on links to files

Ok that actually makes sense and it means the problem is with my setup. When we created our site in BigTree we were essentially moving over an existing site with content which meant that we had tons of links that needed to still work without us going in and changing them. Due to some bad practices by previous people I have links for files/photos/whatever that exist like /hr/docs/myfile.pdf and I also have a page that is /hr. So in order for a folder named hr to exist and the page, I commented out that check for whether or not a directory already exists. So it's going to return false every single time it checks if a similar directory exists. In light of that, do you know which function I should modify to get it to avoid making IPLs if I first do a search on a given list of file extensions? Does that seem like the best way to go about it?

Thanks

Offline

#4 January 29, 2015 12:57pm

timbuckingham
Administrator
From: Baltimore, MD
Registered: April 2, 2012
Posts: 970

Re: Appending / on links to files

Add this code to the top of the makeIPL method in the BigTreeAdmin class (core/inc/bigtree/admin.php):

// See if this is a file
$local_path = str_replace(WWW_ROOT,SITE_ROOT,$url);
if (file_exists($local_path)) {
	return $this->replaceHardRoots($url); 
}

Offline

#5 January 29, 2015 4:53pm

jmason03
Member
Registered: January 9, 2014
Posts: 123

Re: Appending / on links to files

Awesome! Thank you so much for your help on this!

Offline

Board footer

Powered by FluxBB

The Discussion Forum is not available on displays of this size.