Select Document Tags
Hello,
I am having a difficulty.
I currently select a list of documents from a library like this.
/// <summary> /// Selects a list of documents for the user to view /// </summary> /// <returns>A list of conformed contract documents</returns> public static IEnumerable<Document> SelectUserDocuments(string libraryName) LibrariesManager libraryManager = LibrariesManager.GetManager(); IEnumerable<Document> docs = libraryManager.GetDocumentLibraries() .Where(dL => dL.Title == libraryName) .First() .Documents .Where(d => d.Status == Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Live) .OrderBy(o => (string)o.Title); return docs; // SelectUserDocuments/// <summary>/// Uploads the selected document to the CDRLs library/// </summary>/// <param name="sender">Sender</param>/// <param name="e">Event Args</param>protected void UploadButton_Click(object sender, EventArgs e) int count = DocumentUpload.UploadedFiles.Count; string[] allowedTypes = Properties.Resources.DocumentAllowedFileExtensions.Split(Properties.Resources.DelimiterComma.ToCharArray()); string error = String.Empty; if (count > 0) foreach (UploadedFile file in DocumentUpload.UploadedFiles) bool properFile = false; foreach (string allowedExtension in allowedTypes) if (file.GetExtension() == allowedExtension) properFile = true; if (properFile == true) // declare the document file and its properties var manager = new LibrariesManager(); Telerik.Sitefinity.Libraries.Model.Document uploadDocument = manager.CreateDocument(); uploadDocument.Parent = manager.GetDocumentLibraries().Where(dl => dl.Title == Properties.Resources.DocumentsLibraryName_CDRLs).First(); uploadDocument.Title = file.GetNameWithoutExtension(); uploadDocument.UrlName = file.GetNameWithoutExtension(); uploadDocument.Extension = file.GetExtension(); uploadDocument.Status = Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Master; manager.RecompileItemUrls<Telerik.Sitefinity.Libraries.Model.Document>(uploadDocument); // upload the document file manager.Upload(uploadDocument, file.InputStream, file.GetExtension()); // publish the document file uploadDocument.ApprovalWorkflowState = Properties.Resources.PublishedWorkflowState; manager.Publish(uploadDocument); manager.SaveChanges(); SystemMessage.Text = SitefinityCommon.BuildSuccessMessage(Properties.Resources.CDRLs_UploadSuccess); else SystemMessage.Text = SitefinityCommon.BuildErrorMessage(Properties.Resources.CDRLs_UploadError_BadType + Properties.Resources.DocumentAllowedFileExtensions_Friendly); //refresh table RefreshDocumentsTable(); else SystemMessage.Text = SitefinityCommon.BuildErrorMessage(Properties.Resources.CDRLs_UploadError_NoFiles); // UploadButton_ClickHi,1. How can I access the tag for returned documents. - you can pass the tag name and then get the tag Id (alternatively you can get the Id straight from the sf_taxa table in the DB. Once you get the Id you can select the documents that have this Id associated with the tags field like this:
var taxManager = TaxonomyManager.GetManager();var taxon = taxManager.GetTaxa<FlatTaxon>().Where(t => t.Name == "tag").Single();var taxonID = taxon.Id;var content = App.WorkWith().Documents().Where(d => ((IList<Guid>)d.GetValue("Tags")).Contains(taxonID)).Get();--wrong thread--
Can you update the link on this page? It is returning a 404.
Hello Solomon,
Thnak you for your note,please find the correct link below:
www.sitefinity.com/.../taxonomies
Regards,
Boyan Barnev
Telerik