8

I want to show only a particular folder in the right pane of a page using a WebPart in SharePoint Foundation 2010. Is this possible? When adding the WebPart, I could only add the document library. I didn't see a way to show only a subfolder there. I also looked at creating a view on the library, but don't see a way to filter for a folder in the view's filtering options. Is this possible?

EDIT:
I found this which mentions manually editing the markup of the WebPart to add a query for the folder to query for the folder name, but no matter what I try, it always says no documents found. I added the field FolderDirRef to my viewable columns to make sure I had the proper folder specified, but I still get nothing. I've tried <Eq> and <BeginsWith> and tried changing the Value tag's type definition from Lookup to Text and without specifying the type. If I add a new document, it gets uploaded to the document library root. Here's the way I'm specifying the query.

<BeginsWith>
    <FieldRef Name='FileDirRef' />
    <Value Type='Lookup'>/DocumentLibraryName/SubFolderIWant/</Value>
</BeginsWith>

EDIT 2:
I've changed the <View>'s Scope property to RecursiveAll as shown below. With no query defined, it shows ALL documents in ALL folders (as expected), but as soon as I specify a query of any kind, it breaks, and resorts so showing no documents at all. To be clear, the WebPart isn't generating an error. It's just saying no documents found.

EDIT 3:
Here's the full view definition

<View Name="GUID" MobileView="TRUE" Type="HTML" Hidden="TRUE" DisplayName="" Url="..." Level="1" BaseViewID="1" ContentTypeID="0x" ImageUrl="/_layouts/images/dlicon.png" Scope="RecursiveAll">
    <Query>
        <Where>
            <Contains>
                <FieldRef Name='FileDirRef' />
                <Value type='Text'>2007</Value>
            </Contains>
        </Where>
        <OrderBy>
            <FieldRef Name="FileLeafRef"/>
        </OrderBy>
    </Query>
    <ViewFields>
        <FieldRef Name="DocIcon"/>
        <FieldRef Name="LinkFilename"/>
        <FieldRef Name="Modified"/>
        <FieldRef Name="Editor"/>
        <FieldRef Name="FileDirRef"/>
    </ViewFields>
    <RowLimit Paged="TRUE">30</RowLimit>
    <Toolbar Type="Freeform"/>
</View>
4
  • What SharePoint version 2007 or 2010? Nov 9, 2011 at 13:16
  • 2010. Will edit ? to specify.
    – Tim Coker
    Nov 9, 2011 at 13:23
  • Can you put in as much of the relavent code as possible? Nov 9, 2011 at 17:35
  • My first suggestion would be to change: <Value type='Text'>2007</Value> To <Value Type='Text'>2007</Value> (A capital T for Type=) Nov 9, 2011 at 18:50

4 Answers 4

6

What I ended up doing was creating a view on the document library and applying the query/scope changes mentioned above to the <View> definition in the new document library's view. The case sensitivity spevilgenius mentioned matters, but even with that correction, I couldn't get the view to work in the aspx page's web part.

The weird thing is that it appears that when you apply a view to a web part list/document library viewer, it looks like Sharepoint copies that view's definition to the web part's definition. And, indeed, if I look at the code of my page now, I see the exact view definition code there as well as my view. It might work if you put the code below directly in the aspx page and skip the step where I created the view on the Document Library. I've been beating my head against this wall since last night, though. Don't feel like trying anymore permutations...

<View Name="{GUID}" Type="HTML" Scope="RecursiveAll" DisplayName="DisplayName" Url="Url-To-View" Level="1" BaseViewID="1" ContentTypeID="0x" ImageUrl="/_layouts/images/dlicon.png">
    <Query>
        <Where>
            <Contains>
                <FieldRef Name="FileDirRef"/>
                <Value Type="Text">FolderIWantToShow</Value>
            </Contains>
        </Where>
    </Query>
    <ViewFields>
        <FieldRef Name="DocIcon"/>
        <FieldRef Name="LinkFilename"/>
    </ViewFields>
    <RowLimit Paged="TRUE">30</RowLimit>
    <Toolbar Type="Standard"/>
</View>
4

Have you considered simply using a Page Viewer Web Part that points to your folder?

Also, I assume you have good reasons to use folders, but your question is typically the reason why people recommend using metadata rather than folders.

1
  • +1 for METADATA
    – shufler
    Dec 9, 2011 at 20:51
2

Unfortunately Sharepoint 2010 Foundation does not allow for permission based metadata which makes restricting which of your users can upload and where they can upload a tad difficult; unless, of course, folders and folder based permissions are implemented.

-2

It works much easier with a content query see this link

2
  • Please summarize the solution in your answer. Post a link to support your answer, but don't just post a link. Links can go bad and disappear any time. If you want to provide an answer that adds value, post the core message here.
    – teylyn
    May 30, 2013 at 9:46
  • Yes, while this may theoretically answer the question, we prefer inclusion of the essential parts of the answer here, and to provide the link for reference. See answer for general guidelines. If you would like to expand this answer (without plagiarising obviously) I'll be happy to undo my downvote ;-)
    – SPDoctor
    May 31, 2013 at 7:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.