SharePoint Cross Site Content Query Web Part - sharepoint

Besides buying a third party, what is the best approach to extending the CQWP control to include content from a seperate site collection?

You can not override the content query webpart to query another site collection. It uses the SPSiteDataQuery http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spsitedataquery.aspx , this is limited to the current site collection. But you could create a custom webpart that has similar function but looks to a site collection by url rather than from the SPContext. Example:
using (SPSite site = new SPSite("http://server/"))
{
// build a SPSiteDataQuery
// include the CAML query
// use the datatable of results to create XML
// use XSLT to transform XML into HTML
}

Actually, we figured it out. We were successfully able to inherit from CQWP and use a ton of reflector to reproduce a lot of the CQWP code and got it working quite well to query other site collections, as well as the current. The code involved was not for the faint of heart though.

Related

Get query string of Sharepoint URL from within SP2013 app

I've got an app in sharepoint 2013, which is showing up inside of an iframe. I'd like to have links to the page that has the app embedded elsewhere, and pass data to my app through those links. Sounds like a job for query strings, right?
However, I can't find a way to get the query string in my app. None of the tokens I tried inserting had it, and I couldn't get it from within javascript because the url for my iframe and for sharepoint are different. Any ideas?
if your app is within the SP page use
document.referrer
to get the full URL including query

How to get web resource content?

My requirement is when selection of a web resource one HTML page should appear with the content of that web resource.
So I thought I will add a plugin which will get the content of a web resource and dynamically create a HTML page.
now the problems I am having:
1) when the plugin should fire. because it should fire on selection of any web resource, and didn't show web resource in entity list in VS project using developer's tool kit.
2) How I can get the GUID of that selected web resource to get the content.
please guide me how I can do this. Is there any alternate way to do this?
Thank you.
It's a bit unclear what you mean but if I got the nature of your problem correctly, this is the answer to your question.
You're not supposed to use a plugin at all. Since this is an operation on the user interface only, JavaScript is the way to go here. You want to dynamically create contents in a IFRAME component and display those to the user. You should implement onsomeevent method and connect the clicking to fire it.
Accessing web resources is not done by their guids but through their name. At least when trying to access cross frame data stored in such a resource. The name is something that you set yourself when you create or upload the resource to the server.
May be i am wrong about this question.
Using JavaScript, you can achieve this as well.
In JavaScript, access selected WebResource with their name, and you can get details of that WebResourse by making an ActiveXObject.
var JScriptWebResourceUrl = "..Path Of WebResource/jquery.1.4.4.min.js";
var xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
xmlHttp.open("GET", JScriptWebResourceUrl, false);
xmlHttp.send();
eval(xmlHttp.responseText);
Now, you can do what you want from here.
Thanks,
Anish

Enabling search for my site that uses rss

my site is here
The main flash app uses rss (or xml) to display data. I'm wondering how I can add search functionality to it. One idea is to create multiple custom rss for each filter and search query, but I thought that it would be a nightmare to add more data later on. So I'm wondering if there's another way to do it?
RSS feed is located here My site is hosted at edicy.com and I can't install any other server side extensions other than use XHTML, XML, HTML and Javascript.
Index your data using a search engine like solr or sphinx then have your flash app talk to the server to post a query to it and retrieve the results in XML

Cannot crawl complex URL's without setting a site-wide rule to 'crawl as http content'

I have pages within a site containing a control that uses a query string to provide dynamic data to the user (http://site/pages/example.aspx?id=1).
I can get my content source to index these dynamic pages only if I create a rule which sets the root site (http://site/*) to 'include complex urls' and 'crawl sharepoint content as http content'. This is NOT acceptable as changing the crawling protocol from SharePoint's to HTTP will prevent any metadata from being collected on the indexed items. The managed metadata feature is a critical component to our SharePoint applications.
To dispel any wondering of whether or not this is simply a configuration error on my part refer to http://social.technet.microsoft.com/Forums/en-US/sharepointsearch/thread/4ff26b26-84ab-4f5f-a14a-48ab7ec121d5 . The issue mentioned is my exact problem but the solution is unusable as I mentioned before.
Keep in mind this is for an external publishing site and my search scope is being trimmed using content classes to only include documents/pages (STS_List_850 and STS_ListItem_DocumentLibrary). Creating a new web site content source and adding it to my scope presents 2 problems: duplicate content in scope and no content class defining it that I know of.
What options do I have?
Just a thought: maybe you should create two data sources, one - SharePoint - for metadata and items and one - HTTP - for the pages. Set rules on each one to exclude the other's content. Would that solve your problem?
I have decided to take a different approach to this problem as combining dynamic http content and sharepoint content into one scope is a non trivial problem and is better suited to a entirely new project and not a retrofit as I was attempting.
If you have dynamic content from a separate system which you want to crawl without sacrificing SharePoint metadata information from the rest of your site it seems the only option is to write a BCS application/search connector, crawl the two content sources separately and combine them with a scope and possibly an extended core results webpart. Good luck!

Issus deleting a site collection

I'm currently doing some test where I try to delete a site collection programmatically. Thereby I realized some strange behavior by SharePoint.
I used the following code to test the site collection deletion.
private static void DeleteSiteCollection(string urlSiteToDelete)
{
SPSecurity.RunWithElevatedPrivileges(delegate()
{
SPWebApplication webApp = SPWebApplication.Lookup(new Uri("http://wssdev06"));
webApp.Sites.Delete(urlSiteToDelete);
webApp.Update();
});
}
So when I call the method with the url of an existing site collection the site collection will be deleted as expected. But when I call the method with null, the empty string or an url which is not connected to a site collection then SharePoint deletes the site collection which resides under root (e.g. http://wssdev06/).
I'm not sure if I'm too dump to use this SPSiteCollection.Delete() method or if I did not understand the conecpt of site collections and managed paths, but I think this a really strange and alarming behavior.
I could repoduce this behavoir on different web application but had no option to test in on another SharePoint environment yet.
So am I doing something wrong or is this a bug?
UPDATE:
So I did some more investigations and realized that this must have something to do with the indexer of the SPSiteCollection class which returns the root site collection if there is no site collection located under the given url. Looks like a bug.
Whenever you ask SharePoint to find a Site Collection using an Url it'll do it's best to return a SPSite even if it means that it'll have to ignore part of the Url.
Sometimes this is a very good thing. f.i. if you have the full url of a list and want to find the corresponding SPSite and SPWeb.
But it can be very dangerous like when you're deleting Site collections and maybe make a spelling mistake.
If you want to make sure you get the right Site Collection the lookup the SPSite first and check that the SPSite you get has the Url that you want.
BR
Per
Your code looks right. One thought would be to add a check of the sites collection to make sure the site you want to delete is in the sites collection. I realize this does not answer your question.
This sounds like exactly the issue described in Microsoft's KB 968474 - stsadm can inadvertently delete a root site collection if erroneous URL path used. Similar to your symptoms, when using stsadm - o restore, "If the URL path is incorrect then the deletion and restore is attempted against the only valid path which is the root site collection of the URL."
It sounds to me like there is some bug in the underlying site delete API, as you suspected. Possibly, the algorithm looks for a "closest match" rather than "exact match".
Enumerating the Site Collections and validating an exact match might be the best way to avoid this. However, I wouldn't say you're doing anything wrong as this is very close to the Microsoft sample code and the documentation for the function gives no warning about passing invalid URLs.

Resources