SharePoint Content Query Web Part - Ignore Current Level

Consider this hierarchy of a SharePoint site:

- Site Collection
 - Site1
     - Subsite1
         - AnotherSubsite1
             - Page1
             - Page2
         - AnotherSubsite2
     - Subsite2
         - Page3
         - Page4
 - Site2

      

It can be assumed that each site in the specified hierarchy has a default page.

If I put the CQWP on the default Site1 page, can I instruct it to start fetching data one level down where it was placed? those. ignore the page / site it is currently on so that it returns:

     - Subsite1
         - AnotherSubsite1
             - Page1
             - Page2
         - AnotherSubsite2
     - Subsite2
         - Page3
         - Page4

      

thank

+2


source to share


1 answer


I would extend CQWP and then plug in my own ProcessDataDelegate to remove unnecessary data. For example:

protected override void OnInit(EventArgs e)
{
    this.ProcessDataDelegate += ProcessItems;
}

public DataTable ProcessItems(DataTable data)
{
    // Query the DataTable and remove unnecessary information
}

      



The WebId column data

is the GUID for the SPWeb object for each returned item. Take a look at the SPWeb.IDs of the sites you no longer want, and then remove those lines. Note that the GUIDs in the WebId column are uppercase and in the "D" format, as described in Guid.ToString () .

Remember to use AcceptChanges()

at the end to update the DataTable.

+3


source







All Articles