Hi I'm working on my first episerver project and have a problem regarding a css based design where relative urls are required (i.e. in the background-image url).
I dont want to use the filesystem with every little design image in my site so I just have a folder in the root named Images.
My questions are:
Does episerver have a way to make a relative path to the root of the application?
How can I obtain the rewritten path as fx "http://localhost:6666/da/public-root/page2/"?
When i request the url i get the actual url: http://localhost:6666/page2.aspx?id=19&epslanguage=en instead.
Hope someone can help
i do not really know what you actually mean but you can use
for your backround images in css. But you will probably have to keep your css files together with you images folders.
Please look at the publictemplates or the demo templates for examples. If you would like to obtain the rewritten path you could turn the Friendly URL on in web.config. If you are developing directly in Visual Studio and are using an SDK Project you will have to insert some sections in web.config. But then again you can look att the demo package or install a site via the manager and look at the web.config in that project for some examples.
Hi thanx for the reply.
I wrote a method to lead back to the root of the site with the Request.RawURL, which as it turned out, was the url data I was looking for.
The problem arose because I have some usercontrols with the css in the actual aspx page. but of course I could have all the css files in a css folder :)
I have a similar question. I'd like a way to let the editors choose a background image for a page. I'm sure it must be very simple but I'm not succeeding.
My attempt: I added a property to the page called 'backgroundImage' with property type ContentReference (I've tried several other types with no better results).
Now, all I have to do is get hold of the path to that image in the .cshtml page. If I put @Html.DisplayFor(m => m.backgroundImage) it generates a nice little anchor with href = '/globalassets/koala.jpg'. But I can't figure out how to get at that path so I can stick it into a 'style=background-image:@whatever'.
I put a breakpoint in the .cshtml to examine the contents of the Model and can't figure out where this information is hidden.
Any enlightenment would be greatly appreciated.
Solved it this way:
1. add extra [Ignore]d property to model for backgroundImagePath
2. in the controller: currentPage.backgroundImagePath = UrlResolver.Current.GetUrl(currentPage.backgroundImage);
3. use that property in .cshtml
I'd like to know if there's a better way.