locked
How to display a list of files with their relative paths RRS feed

  • Question

  • Hi!

    I would like to create a "Latest changes" view for a document library. The view should list only the files (not folders) and display the relative path of each file inside the library.

    A simplified example of the library would be:

    Folder1

       -file1.1

       -file1.2

    Folder2

       -file2.1

       -file2.2

       Folder2.1 

          -file2.1.1

          -file2.1.2

     

    So, for example for the "file2.1.2", the view should display the path "Folder2/Folder2.1".

    I'm guessing that creating the view displaying the file path could be possible to accomplish using either Content Query Web Part or Data View Web Part, but so far I haven't been able to discover how to do this.

    Any suggestions?

    Thanks!

    Wednesday, November 2, 2011 2:30 PM

Answers

  • Hi ,

     

    I added a column called ‘ relative url’ on the library .And add a workflow on the library to start when a document is created and set the ‘relative url ’ column to get the value of Relative URL of the document .

     

    Modify the view to show items without folder and group by ‘Relative view’ .When view the list in a dataview web part you can  add a formular on the relative url column to get  the substring of the relative url : substring-after($thisNode/@relativeurl,'Shared Documents') .Then the Relative url will be only the folder and the file name  .

     

    Thanks,

    Entan Ming

    • Proposed as answer by Marijn SomersMVP Friday, November 4, 2011 7:50 AM
    • Marked as answer by -ThomasT- Tuesday, November 8, 2011 2:27 PM
    Friday, November 4, 2011 5:50 AM

All replies

  • Hi ,

     

    I added a column called ‘ relative url’ on the library .And add a workflow on the library to start when a document is created and set the ‘relative url ’ column to get the value of Relative URL of the document .

     

    Modify the view to show items without folder and group by ‘Relative view’ .When view the list in a dataview web part you can  add a formular on the relative url column to get  the substring of the relative url : substring-after($thisNode/@relativeurl,'Shared Documents') .Then the Relative url will be only the folder and the file name  .

     

    Thanks,

    Entan Ming

    • Proposed as answer by Marijn SomersMVP Friday, November 4, 2011 7:50 AM
    • Marked as answer by -ThomasT- Tuesday, November 8, 2011 2:27 PM
    Friday, November 4, 2011 5:50 AM
  • Hi Entan!

    Thank you for your reply!

    Could you be a bit more specific about how to add the workflow and setting the "relative url" column to get the value of Relative URL of the document? Do you need to create a custom workflow for this?

    Thanks!

     

    Friday, November 4, 2011 9:18 AM
  • Hi ,

     

    Here are the detailed steps to create the workflow:

    1.       Open your site in SharePoint designer .

    2.       Choose Workflow folder on the left Navigation part .Then choose List workflow in the ribbon .

    3.       Specify the list as your Document library .

    4.       Add an action ‘update list item ’ or ‘set field value in current item’ .

    5.       Specify the column as ‘relative url’ .And set the value of current item ‘Server Relative URL’ .

    6.       Save the workflow .and open the workflow again in the workflows list .Change the workflow to start when an item is created .

    7.       Publish the workflow.

     

    Thanks,

    Entan Ming

    Friday, November 4, 2011 12:14 PM
  • Thank you very much Entan!

    I will definitely look into your suggestion.

    Monday, November 7, 2011 3:12 PM
  • Ok, I'm almost there...I did exactly how you suggested, but I can't seem to make the substring-after($thisNode/@relativeurl,'Shared Documents') work...it displays nothing after I refresh the page in browser. I'm able to have the entire path displayed (.../subsite/list/folder1/...) if I just use the default @relativeurl. Is there still something I need to do?

    One more thing. I'm just wondering about the workflow...I guess it's not necessary if you want to use only the Data View, since there is a possibility to use the "Path" column, which basically leads to the same result (without displaying the file name). Still, the workflow is needed for fetching the path for the "Relative url" column if you want use the standard List View.

    Thanks!

    Tuesday, November 8, 2011 12:48 PM
  • Ok, first of all sorry about my poor knowledge about xslt, but I was finally able to make it work just as Entan suggested. I used substring-after($thisNode/@relativeurl,'Shared Documents') where Shared Documents = the name of my library.

    Thanks!

    • Edited by -ThomasT- Tuesday, November 8, 2011 2:25 PM
    Tuesday, November 8, 2011 2:24 PM