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

Forums / Developing with Sitefinity / Additional url for library file?

Additional url for library file?

9 posts, 0 answered
  1. Duncan Evans
    Duncan Evans avatar
    122 posts
    Registered:
    07 Jul 2009
    25 Aug 2009
    Link to this post
    Is there a way to add a url to a library file. For example we had a old website with a pdf file, this file is being linked to from other websites when checking Google Webmaster Tools. We then migrated to Sitefinity and placed the file in one of a doc libraries. I would now like to add the old url to the file to the library file so other websites and Google can still find it.

    Any ideas?

    Duncan
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    25 Aug 2009
    Link to this post
    Hi Duncan Evans,

    I think that adding a new metakey that will store the url will do the trick. Does this help?

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. Duncan Evans
    Duncan Evans avatar
    122 posts
    Registered:
    07 Jul 2009
    25 Aug 2009
    Link to this post
    Maybe... Could you explain?
  4. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    26 Aug 2009
    Link to this post
    Hello Duncan Evans,

    To add a custom metakey you have to take the following steps:

    1) Go to your web.config file and find the <metaFields> tag. Add the following to the metafield collection:
    <add key="Libraries.URL" valueType="ShortText" visible="True" searchable="True" sortable="True" defaultValue="" /> 

    2) In the web.config find the <libraries defaultGenericProvider="Libraries"> config section. There under <libraryInfo> add the URL metakey to the library items you want it available, e.g. Image:
    add name="Image" title="Image Library" defaultExtenstions=".png, .jpg, .jpeg, .gif" metaKeys="Author, AlternateText, Extension, Name, Height, Width, Size, Category, URL"></add> 

    3) At this point after saving the web.config and restarting the web site you will have the URL metakey available at your disposal. Here is an example of how to set up a textbox to input the URL when editing Image items, in the Libraries module. You will have to add the following to the ~/Sitefinity/Admin/ControlTemplates/Libraries/LibraryItemEdit.ascx and then map the external control template:
    <sfGCn:ContentMetaFields ID="imageMetaFields" runat="server"
       <ItemTemplate> 
       ... 
       <li> 
       <asp:Label ID="Label11" runat="server" AssociatedControlID="URL" Text="URL"></asp:Label>  
       <asp:TextBox runat="server" ID="URL" TextMode="MultiLine"></asp:TextBox>  
       </li> 
       ... 

    I hope that this information will clarify the issue.

    Sincerely yours,
    Rado
    the Telerik team

    Instantly find answers to your questions on the newTelerik Support Portal.
    Check out the tipsfor optimizing your support resource searches.
  5. Duncan Evans
    Duncan Evans avatar
    122 posts
    Registered:
    07 Jul 2009
    27 Aug 2009
    Link to this post
    Well i did all that, and the URL field does show in the control but when navigating to the given URl it just gives me a 404 error? Should i add a mapping in IIS for pdf files?
  6. Duncan Evans
    Duncan Evans avatar
    122 posts
    Registered:
    07 Jul 2009
    27 Aug 2009
    Link to this post
    Adding a IIS extension mapping does not work either.
  7. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    28 Aug 2009
    Link to this post
    Hi Duncan Evans,

    There must be something wrong with how you are setting the value of this field. Could you send us a sample code of how you set the URL field?

    Best wishes,
    Rado
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  8. Duncan Evans
    Duncan Evans avatar
    122 posts
    Registered:
    07 Jul 2009
    28 Aug 2009
    Link to this post
    Well i did what you suggested.

    I added this line to the web.config for the metafield:

    <add key="Libraries.URL" valueType="ShortText" visible="True" searchable="True" sortable="True" defaultValue="" /> 

    I modified the LibraryInfo part of the web.config to include the new meta field (for documents)
    <add name="Document" title="Document Library" defaultExtenstions=".doc, .docx, .rtf, .txt, .pdf, .ppt, .pps, .pptx, .html, .xls, .xlsx" metaKeys="Author, Description, Extension, Name, Size, Category, URL"></add> 

    I then added the textbox to the LibraryItemEdit.ascx file:

    <sfgcn:contentmetafields id="itemMetaFields" runat="server"
    <ItemTemplate> 
    <h3> 
    <asp:Literal ID="Literal11" runat="server" Text="<%$Resources:ItemEdit_Details %>"></asp:Literal></h3
    <fieldset class="set"
    <ol class="setIn"
    <li> 
    <asp:Label ID="Label7" AssociatedControlID="Author" runat="server" Text="<%$Resources:ItemEdit_Author %>"></asp:Label> 
    <asp:TextBox runat="server" ID="Author"></asp:TextBox> 
    </li> 
    <li> 
    <asp:Label ID="Label5" runat="server" AssociatedControlID="Description" Text="<%$Resources:ItemEdit_DocumentDescription %>"></asp:Label> 
    <asp:TextBox runat="server" ID="Description" TextMode="MultiLine"></asp:TextBox> 
    </li> 
    <li>  
    <asp:Label ID="Label11" runat="server" AssociatedControlID="URL" Text="URL"></asp:Label>   
    <asp:TextBox runat="server" ID="URL" TextMode="MultiLine"></asp:TextBox>   
    </li>  
    </ol> 
    </fieldset> 
    ... 

    The new field shows up in the admin pages. I have tried adding ~/mypathtothedocument/documnetfilename.pdf, I also tried /mypathtothedocument/documnetfilename.pdf and a fully qualified path http://localhost/mypathtothedocument/documnetfilename.pdf

    Did i miss something?

    Duncan
  9. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    31 Aug 2009
    Link to this post
    Hello Duncan Evans,

    "We then migrated to Sitefinity and placed the file in one of a doc libraries"

    If the file is stored in one of Sitefinity's libraries you cannot use its default extension. Once the file has been uploaded it extension is sflb.ashx. If you want to use the original file extension, please take a look at the following KB articles:

    - Use real file extension.
    - How to filter the default ContentHttpHandler by extension

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Register for webinar
9 posts, 0 answered