OrchardCMS / OrchardDoc

Documentation for Orchard 1.x (not Orchard Core, for that see https://docs.orchardcore.net/).
http://docs.orchardproject.net
142 stars 242 forks source link

Absolute path in RegisterLink? #303

Closed jean closed 8 years ago

jean commented 8 years ago

Here I see code like this: Url.Content("~/modules/orchard.themes/Content/orchard.ico").

Why would one ever have absolute paths in theme templates? Isn't the view engine supposed to resolve such paths to the current theme or root application?

I asked this in a StackOverflow comment too.

rtpHarry commented 8 years ago

In this case it's a snippet from the Orchard.Core project referring to the Themes module which is a core module and therefore and cannot be disabled:

image

I guess it's probably as safe as it gets.

I think what you're really getting at is how do you get a path out of the system for the current module / theme. I don't know. I've looked at a lot of modules and they have always either used relative paths (../Content/Images/Something.png) or just given up and hard coded the module path in (~/modules/Some.Module/Content/Images/Something.png). This was kind of safe in the past but a couple of versions ago custom module locations were introduced so the ~/modules/ portion of the path is not certain any more.

Thanks for raising the point, I would be interested in a proper answer if you come up with one but at the moment I'm going to close this issue as it's not actually related to the docs, just a questionable practice within Orchard itself.

I would suggest opening a thread on the Orchard Discussion Forums on codeplex, StackOverflow, Orchard Pros, or the Gitter chat room to try and get more info.