1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / associating files with content items

associating files with content items

5 posts, 0 answered
  1. Nick
    Nick avatar
    91 posts
    Registered:
    04 Aug 2008
    17 Oct 2008
    Link to this post
    hello all!

    i have followed your guide in the knowledge base regarding associating files with content items.

    i have this working as expected but there is a slight modification i would like to undertake, which i cannot quite work out how to implement.

    when an image bas been selected to be associated with a content item, the relevant text box is populated with an absolute link (e.g. http://website.com/Libraries/Library/image.sflb)

    is there any way to set this control to return a relative url (e.g /Libraries/Library/image.sflb)?

    I know i could alter this URL via string manipulation when the content item is displayed (as i have also extended the ContentView to cater for my newly associated image), but that is not an ideal solution, whereas setting the url to be relative initially is a lot cleaner of a solution.

    thanks guys,
    Nick
  2. Joe
    Joe avatar
    138 posts
    Registered:
    24 Sep 2012
    20 Oct 2008
    Link to this post
    Hi Nick,

    Thanks for your inquiry.

    This is possible by wrapping the button and the textbox in a user control, then making the textbox show the relative path while a hidden field shows the full path. This article explains the process in more detail. Is this what you meant by string manipulation?

    Sincerely yours,
    Joe
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. Nick
    Nick avatar
    91 posts
    Registered:
    04 Aug 2008
    21 Oct 2008
    Link to this post
    yes, the process appears to be very similar to what i wanted.

    i only wanted this functionality in particular (i.e. notabsolute paths) because i extended the content view control to display generic content in a particular fashion along with the newly associated image. however some images were not displaying and i worked out this was down to image path's being absolute rather than partial.

    so, rather than wrapping the button and text thing in a control itself, i just moved the logic for stripping the path into the extended content view, keeping the file association control as you explained it in your KB article.
  4. Pepi
    Pepi avatar
    981 posts
    Registered:
    31 Jan 2017
    27 Oct 2008
    Link to this post
    Hi Nick,

    We would recommend you modify the returned URL via string manipulations. Unfortunately, we cannot provide you with another solution. Why do you think it is not a good and clean approach to achieve the required functionality?

    Greetings,
    Pepi
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  5. Nick
    Nick avatar
    91 posts
    Registered:
    04 Aug 2008
    27 Oct 2008
    Link to this post
    i guess it's just a potentially less error prone method, if the URLs are coming out at the source (i.e. the image selector) as relative, rather than having to modify the URL later using string operations to chop them down. Talking of chopping, consider this analogy: if you needed some wood for some building work, you wouldn't buy a tree and process it into a usable state yourself, you'd buy the wood pre-processed, because who knows what could go wrong otherwise! but if its the only solution i guess it will do :-)

    as always thanks very much for the help!
Register for webinar
5 posts, 0 answered