Site Listing in DVWP

Dec 1, 2010 at 4:42 AM

I would like to populate a DVWP that lists all the sites that a user has access to in the Site Collection. Considering that this will go on the landing page, I would like to optimize the JQuery/Javascript where possible so the results are displayed as soon as possible. Would this be a good time to set async = true?

$(document).ready(function(){

		var siteList = "";
		var newTR = "";
		var url,title,userPerm;
		var image = '/sitecollectionimages/stsicon.gif';
		
		$().SPServices({
			operation:'GetAllSubWebCollection',
			async:false,
			completefunc: function (xData,Status){
				//alert(xData.responseXML.xml);				
			 	$(xData.responseXML).find("[nodeName=Web]").each(function(){
			 			url 	=$(this).attr("Url");
			 			title   =$(this).attr("Title");
			 		$().SPServices({
			 			operation:'GetRolesAndPermissionsForCurrentUser',
			 			webURL: url,
			 			async: false,
			 			completefunc: function(xData, Status){
			 			 	userPerm =$(xData.responseXML).find('[nodeName=Permissions]').attr('Value');
			 				if(userPerm >= 756052856897){   //View Only permission
			 					var newTr = '<tr><td class="ms-vb"><img src="/sitecollectionimages/stsicon.gif"> ' + title + '</td></tr>';
			 					$('#WebPartWPQ3').find('tbody').append(newTr);	
							}//end if
						}//end completefunc
					}); //end GetRolesAndPermissionsForCurrentUser
				});//end responseXML For Each  	
			}//end completefunc
		});//end GetAllSubWebCollection 
});	

Thanks in advance
Marcus

Coordinator
Dec 1, 2010 at 1:55 PM

Setting

async: true

 will simply alow the processing to continue without waiting for the results. Since you are nesting your Web Services calls, you won't want to set async: true on the outer call for sure, and probably not on the inner one. You can expereiment to see what works.

In any case, changing the valiue of async will have zero impact on the amount of work that the browser needs to do.

All *that* said, you might want to do this with a DVWP rather than script. Take a look at DataSourceMode="Webs".

M.

Dec 1, 2010 at 11:28 PM

Marc

Am I headed in the right direction? A DataSourceMode="Webs", selectcommand="Webs Scope=’SiteCollection’></Webs>"? Will I need <Lists ServerTemplate='100'></Lists> in my CAML? First I would like to grab all of the site names in the SiteCollection. Next, modify the CAML to verify if the user has access. I've been reading your articles trying to piece it together.http://sympmarc.com/2008/09/21/rollup-data-view-web-parts-revisited/, http://sympmarc.com/2008/02/19/rolling-up-content-in-sharepoint-using-the-data-view-web-part-dvwp/, http://sympmarc.com/2008/09/21/rollup-data-view-web-parts-revisited/

Great work and Thanks

Marcus

 

Coordinator
Dec 2, 2010 at 2:49 AM

Marcus:

Just using DataSourceMode="Webs" ought to return the list of Webs in the current Site. (Remember that in this language, Site='Site Collection' and Web = 'Site'.) The list sghoulds be permission trimmed for the current user. You don't need the <Lists ServerTemplate='100'></Lists> filter, as that's about what type of list it is.

M.

Dec 2, 2010 at 3:05 PM

Unfortunately nothing is happening. I know I'm missing something simple.

<WebPartPages:DataFormWebPart runat="server" IsIncluded="True" NoDefaultStyle="TRUE" ViewFlag="0" Title="Test" ListName="{DCCBF01D-5CB5-42BC-A5C5-2EF37F21B7DD}" Default="FALSE" DisplayName="Test" __markuptype="vsattributemarkup" partorder="1" __WebPartId="{0FF0E63B-4A77-49A1-A029-4957AB47BED4}" id="g_0ff0e63b_4a77_49a1_a029_4957ab47bed4">
	<DataSources>
		<SharePoint:SPDataSource runat="server" DataSourceMode="Webs" UseInternalName="true" selectcommand="&lt;View&gt;&lt;/View&gt;" id="Test1"><SelectParameters><WebPartPages:DataFormParameter Name="ListID" ParameterKey="ListID" PropertyName="ParameterValues" DefaultValue="{DCCBF01D-5CB5-42BC-A5C5-2EF37F21B7DD}"/>
						</SelectParameters><DeleteParameters><WebPartPages:DataFormParameter Name="ListID" ParameterKey="ListID" PropertyName="ParameterValues" DefaultValue="{DCCBF01D-5CB5-42BC-A5C5-2EF37F21B7DD}"/>
						</DeleteParameters><UpdateParameters><WebPartPages:DataFormParameter Name="ListID" ParameterKey="ListID" PropertyName="ParameterValues" DefaultValue="{DCCBF01D-5CB5-42BC-A5C5-2EF37F21B7DD}"/>
						</UpdateParameters><InsertParameters><WebPartPages:DataFormParameter Name="ListID" ParameterKey="ListID" PropertyName="ParameterValues" DefaultValue="{DCCBF01D-5CB5-42BC-A5C5-2EF37F21B7DD}"/>
						</InsertParameters>
					</SharePoint:SPDataSource>
	</DataSources>
	<ParameterBindings>
				   <ParameterBinding Name="ListID" Location="None" DefaultValue="{DCCBF01D-5CB5-42BC-A5C5-2EF37F21B7DD}"/>
				   <ParameterBinding Name="dvt_apos" Location="Postback;Connection"/>
				   <ParameterBinding Name="UserID" Location="CAMLVariable" DefaultValue="CurrentUserName"/>
				   <ParameterBinding Name="Today" Location="CAMLVariable" DefaultValue="CurrentDate"/>
			   </ParameterBindings>
	<datafields>@ID,ID;@ContentType,Content Type;@Title,Title;@Modified,Modified;@Created,Created;@Author,Created By;@Editor,Modified By;@_UIVersionString,Version;@Attachments,Attachments;@File_x0020_Type,File Type;@FileLeafRef,Name (for use in forms);@FileDirRef,Path;@FSObjType,Item Type;@_HasCopyDestinations,Has Copy Destinations;@_CopySource,Copy Source;@ContentTypeId,Content Type ID;@_ModerationStatus,Approval Status;@_UIVersion,UI Version;@Created_x0020_Date,Created;@FileRef,URL Path;</datafields>
	<XSL>

Dec 2, 2010 at 11:07 PM

Marc

Just wanted to let you know that once I closed and reopen the page in designer everything appeard. :-)

Thanks again

Coordinator
Dec 3, 2010 at 1:46 AM

Excellent, Marcus. Glad you got it working.

M.