Sometimes you want to show some items from a List in another Site Collection or Web Application (or even another Farm). This can't be done with out of the box webparts. The next javascript which you can paste in de default content editor webpart (source editor) can help you in this situation.
- Go to the site where you want to show your list items (not the location of the list)
- Download the file http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js
- Put this file in a document library in your site
- Copy the url (e.g. http://mysite/documentlibrary/jquery-1.3.2.min.js)
- Edit your page and paste a content editor wepart on your page
- Go to source editor (of the webpart properties of the content editor webpart)
- Put the next code into your content editor webpart
<script type="text/javascript" src="http://mysite/documentlibrary/jquery-1.3.2.min.js"></script> <script type="text/javascript"> $(document).ready(function() { var soapEnv = "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'> \ <soapenv:Body> \ <GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'> \ <listName>libraryname</listName> \ <viewFields> \ <ViewFields> \ <FieldRef Name='Title' /> \ <FieldRef Name='ID' /> \ </ViewFields> \ </viewFields> \ <rowLimit>5</rowLimit> \ </GetListItems> \ </soapenv:Body> \ </soapenv:Envelope>"; $.ajax({ url: http://corporatesite/site/_vti_bin/lists.asmx, type: "POST", dataType: "xml", data: soapEnv, complete: processResult, contentType: "text/xml; charset=\"utf-8\"" }); }); function processResult(xData, status) { $(xData.responseXML).find("z\\:row").each(function() { var liHtml = "<li><a href=\"http://corporatesite/site/list/listname/DispForm.aspx?ID=" + $(this).attr("ows_ID") + "\">" + $(this).attr("ows_Title") + "</a></li>"; $("#tasksUL").append(liHtml); }); }</script>
No comments:
Post a Comment