Multi sourced document library.... More Info
hi,
i have a requirement for a document library where some of the entries are in sharepoint, and others are actually hyperlinks to content in another, non-sharepoint, web site. That is, one item in the document library is a normal sharepoint lodged document, whilst the next is really just the meta-data with the URL pointing outside of SP and when you click on it you go there. Its sort of like combining a document library list and a links list in one.
I have tried programatically adding new items to the document library which are external URL's. This doesnt work, it just loads the file into SP.
I have also tried altering an existing item and changing its "URL Path" field. This doesnt work also as it appears to be a read only field.
Does anyone have a clue how to try to do this? Is there some other approach?
Thanks in advance,
Ross
Hi,
since above post ive managed to configure a document library with two content types, both documents and links which exactly what i want. Now i want to be able to create the links programatically as stated above. I have the below but I get an exception on the line below marked BANG!!! which has the message:
"To add an item to a document library, use SPFileCollection.Add()
SPSite mySiteCollection = new SPSite("http://cbr02dw2295752:37121/");
SPWeb mySite = mySiteCollection.AllWebs["Case-2007071"];
SPList list = mySite.Lists["Shared Documents"];
SPListItemCollection listItems = list.Items;
SPFieldUrlValue fuv = new SPFieldUrlValue();
fuv.Description = "Something";
fuv.Url = "http://cbr02dw2295752:31145/fred.doc";
SPContentType spt = list.ContentTypes["Link to a Document"];
SPListItem newItem = list.Items.Add();
newItem["ContentTypeId"] = spt.Id;
newItem.Update(); // BANG!!!
newItem["URL"] = fuv;
newItem["Name"] = "My2ndRecord";
newItem.Update();
Does anyone know how to create document links, rather than documents, in a document library. I cant figure out any parameters to SPFileCollection.Add that are at all useful and the doco is pretty limited at the moment. The above code also does not seem to work for document libraries. I have also tried using SPDocumentLibrary casts from SPList but it makes no difference.
HELP PLEASE!!!!
I do not have a source code for this, but here is the direction. You have to add new SPFile to the document library. It must contain HTML code with link to external URL. You can use page refresh written in javascript or simply
META-REFRESH tag. Please post the results.