Relative path switch? Why?

Topics: General, Troubleshooting
May 6, 2011 at 3:39 PM

I have got a site rendering images, scripts and styles OK in some sections (homepage, /blog, /bio, /whatever). however, when i try accesing the blog archives module (I mean, hitting the March archive for example), the render is a mess. Its like the site path is changed and all resources arent found. Why would this happen? I mean, why is it taking one address at some places (relative) and another at the blog archives section?


At /blog i just load an image with <img src="Themes/MyThemeName/Content/Images/...jpg" />, and it renders ok. But in the blog archives the rendered tag is <fullurl>/blog/archive/march/2011/THEMES/MYTHEMENAME/CONTENT/IMAGES/...jpg" />, for example. Is it weird or am i messing up?

May 6, 2011 at 4:29 PM

You should have a / in front of your URLs so they are absolute.

If you paste in your view code maybe I can see what's wrong.

May 6, 2011 at 4:39 PM

Yeah sorry, i misspelled that as i wasnt copying from my code. Anyway, the "/" in front of the url wont work neither. I have read this and using something like @Html.Image("~ seems to be my catch. But how can i include that in a HTML widget? 

I can fix all pages to use @Html.Image but what about html widget content with images? thanks

May 6, 2011 at 4:43 PM

Hmm... why won't the "/" work exactly?

May 6, 2011 at 4:51 PM

Using src="/Themes/DarrahJane/Content/Images/BodyDividerDotted.gif" the /OrchardLocal/ is missing in all urls. I have set my base url to http://localhost:30320/orchardlocal, so i thought it should do it right? what may be wrong?

May 6, 2011 at 4:57 PM

Ah yeah for images in HTML content there will be problems. This is something else I want to tackle in Media Garden, I have some ideas to automatically fix URLs as well as generate resized images for HTML editor content.

Anyway see my answer in your other thread, it might be possible to run Razor code in HTML content (although there are serious caveats with that if anyone other than yourself is going to be updating content!)

May 6, 2011 at 6:59 PM

Mm well i tried in many ways and ended up guiving up. I should read the docs for Razor and feedback this again. I fixed my problem using the MediaManager built in for Orchard, and that generates a url that persists through all requests (dont know why the traditional wont !!). However, its an awkward but functional fix. Thanks again!!

May 6, 2011 at 8:34 PM

I'll let you know when I've tackled this, it's something I'd like to see working properly as well!