How to add a webpart to every document library (existing and future) - sharepoint-2010

I'm working on a webpart for SharePoint 2010 and I would like to know how to config it to work in every existing and future document library. It won't be good for the project to add it every time a new document library is created.
Any ideas?

You need to create a custom List Definition which will include its own AllItems.aspx with your custom web part embedded.
However, this will work if you create the library of this template in future not for others.
Other solution could be to have your web part as a web server control and include it in your master page. This way, the control can find out if there is any ListView web part is present on page.

Related

Dynamic slide show in SharePoint 2013

How to build a slideshow(dynamic) in SharePoint 2013. I have already tried OOTB but all of them are static.I have also tried some java script but even scripting cannot give create dynamic slide show.
By dynamic I mean that if I edit the list/library (from SharePoint itself) that change must be reflected back on the slide show. Can anyone help?
There is sevrals solution.
You could use the SharePoint Search and the display template for generate you slideShow.
You can find a tuto here : Image Slider with SharePoint 2013 Search Results Web Part
Or you can dev it with pure JS script.
A SIMPLE JQUERY CONTENT SLIDER

NullReferenceException in SharePoint 2010 page layout after restore

It is SharePoint 2010 publishing website. I have a page layout with some user controls added to it. These users controls have rad editor controls in them. Everything was working perfectly unless one day I restored a backup from production to my dev and test environments. This page on dev and test environments started to give "System.NullReferenceException: Object reference not set to an instance of an object.". When I debug the controls are actually null, and debugger comes directly to set function for the fields, it does not call page_load function before coming to setter.
These same controls are working in other page layouts even after backup restore. The only difference I see in page layouts where these controls work and don’t work is AutoEventWireup="true". I tried adding this attribute to the page layout which is not working but SharePoint started to give error that this attribute is not allowed. Now no matter what I do, add or remove this attribute from my layout I keep getting error.
Another difference I noticed is that this layout was previously updated, other layouts were most probably never updated after website was migrated from MOSS 2007 to SharePoint 2010.
The only way I can make these pages work is by removing these controls from the page,
please help me find a solution to this situation. I have already read a bunch of articles about "AutoEventWireup" I am not sure if this is the problem, nothing seems to provide a solution in my current situation.

Cannot add WebPart to master page using SharePoint Designer

I've built a WebPart for a SharePoint 2010 site. I need to add it to one of its master pages (using SharePoint Designer), and when I select it from the WebParts menu I click it but I don't see it added on the design page...
Could you please tell me how to do it?
Thanks in advance!
Brian
Typically, the Web parts get added to Pages (in a Web Part Zone) not the master page. You can force this by entering Advanced Edit mode in SPD and add a Web Part Zone & Web Part but it is not the way in which Master Pages were intended to be used.

how to remove the new document option in sharepoint.

I have form library in sharepoint 2010. In that library list workflow is associated. Whenever any document is added to
the library, new document symbol in green color is appearing behind the document.I have googled and got to know that
duration of new document symbol can be reduced or extended using code or command.
My requirement is: First time when document is loaded new document symbol should be there. But when approver approves the document that new document symbol should be disappeared. Is there any way to do this??
Any help is appreciated.
If I had to do this, I would use jQuery to check the status of the document client side. If the document is approved, then change the css of the image element so it was no longer displayed (display:none).
It's not exactly an answer to you question, but it's worth mentioning that there is an out-of-the-box command allowing to change the number of days the "New" icon is displayed:
stsadm -o setproperty -pn days-to-show-new-icon -pv 42
How to stop the !New tag from appearing when you add items to your SharePoint Team Services and SharePoint Services Web site
Days-to-show-new-icon: Stsadm property

Web part in only Document Library pages

I've built a web part for SharePoint 2010.
Using SharePoint Designer I've got it to work on every page within the site, but then I realized that I only want it to work when users navigate document libraries.
Is there any way to do that? If not, how can I check that condition from the web part?
Using SharePoint Designer I've got it
to work on every page within the site
Does this mean you have embedded it in the master page?
A quick and dirty way; you could check the url for /Forms/ and only show it then.