Listing Sharepoint documents with title and not name

Vote:
 

Hi,

does anyone know how you can expose a sharepoint document title rather than the name?  In a TreeNodeBinding (of a treeview control) you cannot set the TextField property to title (only the ToolTipField property) and in the code behind the VirtualFileBase class only has relevant methods for Name and VirtualPath when setting the text of each of the nodes (which overides the TextField property anyhow).

Thanks

#60529
Aug 14, 2012 18:34
Vote:
 

If you are using Connect for SharePoint and reading SharePoint documents over EPiServer.VirtualPathWssProvider, then you can try to cast VirtualFileBase to EPiServer.VirtualPathWssProvider.WssFile. WssFile has Summary property, that contains document metadata including Title.

#60538
Aug 15, 2012 8:50
Vote:
 

Thanks for the reply Sergii.

No, I am just using the local CMS file storage (documents in this case) through a FileSystemDataSource control, bound to the treeview.

Having said that, the site on production server does read sharepoint docs over EPiServer.VirtualPathWssProvider, but either way I am working with the same episerver source code for the document listing (included in the template install).  Also, looks like WssFile is not available to code against (greyed out in reflector).

#60555
Aug 15, 2012 16:02
Vote:
 

Well, if you are using FileList user control from Alloy Tech sample templates - then take a look at FileTree_TreeNodeDataBound method in the control's code behind. It always sets the Text property of the tree node to the Name attribute value. You can updated it like this, in order to get Title instead of Name:

  protected void FileTree_TreeNodeDataBound(object sender, System.Web.UI.WebControls.TreeNodeEventArgs e)
        {
            VirtualFileBase virtualFile = e.Node.DataItem as VirtualFileBase;
            string title = null;
            if (virtualFile.IsDirectory)
            {
                e.Node.SelectAction = TreeNodeSelectAction.Expand;
            }
            else
            {
                e.Node.NavigateUrl = e.Node.DataPath;
                var unifiedFile = virtualFile as UnifiedFile;
                if (unifiedFile != null)
                {
                    title = unifiedFile.Summary.Title;
                } 
            }
            e.Node.Text = Server.HtmlEncode(title ?? virtualFile.Name);
        }

    

#60558
Aug 15, 2012 17:09
Vote:
 

Thanks Sergii, exactly what I was after.

#60578
Aug 16, 2012 9:57
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.