Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Dieter Walckiers 9 posts 29 karma points
    Jan 14, 2012 @ 17:52
    Dieter Walckiers
    0

    Relative paths in templates; removing the leading slash.

    Hello!

    I'm struggling with the following:

    I have a template in Umbraco, and in the "src" attribute of one of the img tags, I add an item field, of the type Upload (pointing to an image obviously).

    This translates into something like:

    <img src="/media/87/logo.gif">

    Now, I'm using Umbraco in a subfolder on the server, this works fine, provided I adapt my paths (to my CSS files etc), removing the leading slash.
    On this item field I'd like to do the same; I'd like the path generated by the upload item field to be "media/..." instead of "/media/...".

    I thought of a javascript hack that automatically fixes the urls, but I guess there's a more elegant way to achieve this?

    Thanks for your time!

    Dyte

  • Dieter Walckiers 9 posts 29 karma points
    Jan 14, 2012 @ 21:50
    Dieter Walckiers
    0

    Slight correction, I don't need to just remove the leading slash, I need my paths all in the following fashion:

    "/subfolder-name/css/..."
    "/subfolder-name/media/..."

    For the hardcodes ones this is easy, but I'm wondering how to do it for the ones that are inserted at runtime, like the upload typed item field.

  • Dieter Walckiers 9 posts 29 karma points
    Jan 16, 2012 @ 19:39
    Dieter Walckiers
    0

    Nobody?

    Basically I'd like to control the format of the paths the Item Fields (e.g. Upload) get translated into.

    "/subfoldername/css/..."

    instead of the default

    "/css/..."

  • Rodion Novoselov 694 posts 859 karma points
    Jan 17, 2012 @ 13:38
    Rodion Novoselov
    0

    Hi. What version do you use? There used to be a submitted issue with 4.7 that's now reported as closed:

    http://umbraco.codeplex.com/workitem/30201

     

  • Dieter Walckiers 9 posts 29 karma points
    Jan 18, 2012 @ 23:53
    Dieter Walckiers
    0

    I'm using 4.7.1.

    I just bumped on a topic in the old forum, where it's mentioned that it's not possible to install Umbraco in a subfolder of the root website.

    Is this still the case?

    Because I do manage to run Umbraco in a subfolder, it's just that the paths to the css etc aren't correct.

    I guess I should modify a setting somewhere to tell umbraco that he shouldn't load his stuff from

    "/CSS/Reset.css"

    but from

    "/subfolder/CSS/Reset.css"

  • Dieter Walckiers 9 posts 29 karma points
    Jan 19, 2012 @ 00:43
    Dieter Walckiers
    0

    So right now I'm using a javascript hack along the lines of:

    var allLinks = document.getElementsByTagName("link");
    for (var i = 0;i<allLinks.length; i++)
    {
    var href = allLinks[i].getAttribute("href");
       if (href.substring(0, 4) == "/css" || href.substring(0, 4) == "/CSS" || href.substring(0, 4) == "/Css")
        allLinks[i].setAttribute("href","/NL" + href);
    }


    But this is a very ugly way of doing things...

Please Sign in or register to post replies

Write your reply to:

Draft