last day (14 days later) » 

10:16
0
Q: Caching of _layout files

Juergen RiemerI store JavaScript files that are used in all of our site collections in the layouts folder hive: C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\TEMPLATE\LAYOUTS\custom\) I reference them in the masterpage like so: <SharePoint:ScriptLink language="javascript" name="cus...

We usually do it manually in masterpage by adding v=1.1 like name="custom/test.js?v=1.1" for example
Thanks for the comment... this is what I wanted to avoid since I'd have a lot of masterpages to update :/
Create a separate control, place all your ScriptLinks in that control and use that control in all your masterpages. That way you would only update single control.
That sounds interesting. Would you have an example? Please create an answer with workable code so that I can accept it.
Are you using Visual studio for the solution? And is it on-premises?
10:16
Yes on both questions, only restriction: no farm solutions.
No farm solutions hmm.. Sandbox Web Part might help but not sure never done it before..
Hi, I just checked.. if we only need to install the farm solution once and all other site collections would not be touched we could install it:) Mind sharing your code as answer?
okay that would be great
i will guide you here if you can follow.. right click on your project, go to add and than SharePoint Mapped Folder
from the new window select Template -> Control Templates and click Add
You should see a ControlTemplates folder and within that a folder named on your project. Right click and click add -> New Item
You should be able to see User Control & Application Page options both are only available in Farm Solutions
can you follow these steps?
oh great thanks.. yes one sec
ok I see them
Add a new control name it anything "CustomScriptLinks" for example. And paste all the ScriptLinks from master page to this control. Make sure that the control is using correct namespace assembly
In controls sometimes <SharePoint:ScriptLink needs to changed to <SharePointWebControls:ScriptLink
Once done, your control is ready to use.. now in your master page use this control using @Register tag
<%@ Register TagPrefix="MyControls" Src="~/_controltemplates/15/ProjectName/CustomScriptLinks.ascx" TagName="CustomScriptLinks" %>
10:33
Ok, in the acsx I have now
<%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
<%@ Assembly Name="Microsoft.Web.CommandUI, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
Than add it inside head using <MyControls:CustomScriptLinks runat="server" />
looks good
one question: can I deploy this farm solution via VS or do I need to upload file to cetnral admin and install? never worked with farm solutions :)
answer: right click on the project and click publish. This will ask for path and create a WSP file in your given folder
once you have WSP file you can use PowerShell to deploy the WSP Solution
search for Add-SPSolution and Install-SPSolution commands
OK great thanks.
I will add this as an answer :)
10:42
great.. thanks.. last question: the
ascx file do I need to anything for the file to get fetched when modified?
deploy the solution again.. Uninstall-SPSolution, Remove-SPSolution, Add-SPSolution and Install-SPSolution - run these commands in exact same order to reinstall
I understand now.. thanks a lot! please post your question I will accept :)

last day (14 days later) »