13

Doing a template refactor, I wanted to add a new base template and move a lot of scattered functionality to this template, including insert options. I did not know exactly where one specific template was configured as an insert option, so I checked the "Navigate" -> "Links". However, every content item using any template that had this single template as an insert option showed up in the list of links (apologies for the large black boxes; had to blank out client content):

a small fraction of the links to this one template

I could browse through this list and find all of the "__Standard Values" items, but that's not very smart (I'm a human, I could very easily miss one or more). Is there a way for me to do a smarter search?

Sitecore 7.2 rev 140526

5
  • Just to clarify, the ask is to identify templates that have a certain item as an insert option? Commented Oct 7, 2016 at 19:33
  • 1
    Some very strange dude said today that the answer to all questions is Sitecore Powershell (SPE). In this case he's probably right. And I'm sure someone here can help you with the command - I had too much drinks already to do that now :)
    – Gatogordo
    Commented Oct 7, 2016 at 19:41
  • @DanSolovay: Yes, that is correct.
    – Ed Schwehm
    Commented Oct 7, 2016 at 19:44
  • @Gatogordo: If SPE works with 7.2, then that's probably a good thing to make as an answer :) I don't know if installing SPE is an option for me in this case though.
    – Ed Schwehm
    Commented Oct 7, 2016 at 19:44
  • Didn't want to answer without a real command to go along.. and like I thought they are others who could pick up were I left..
    – Gatogordo
    Commented Oct 7, 2016 at 19:57

3 Answers 3

14

In my humble Opinion 3 is the best as it works out of the box, no modules required, no code required and what is more important you do not rely on LinkDatabase which can be sometimes outdated.

Option 1

If you can use Sitecore PowerShell Extensions for that. Here you go, complete code snippet

$item = Get-Item -Path "/sitecore/templates/Project/Playground/Page" 
[Sitecore.Globals]::LinkDatabase.GetItemReferrers($item,$true) | %{ $_.GetSourceItem()} | ? { $_.Name -eq "__Standard Values"} 

Option 2

You can easily translate it into C# code and run it in some aspx page to display results.

var item = Sitecore.Data.Database.GetDatabase("master").GetItem("/sitecore/templates/Project/Playground/Page");
var itemReferrers = Sitecore.Globals.LinkDatabase.GetItemReferrers(item, true)
    .Select(link => link.GetSourceItem())
    .Where(i => i.Name.Equals("__Standard Values"));

Option 3

Using modified @dan-solovay approach, get results using Sitecore query:

Open url: http://domain/sitecore/shell/default.aspx?xmlcontrol=IDE.XPath.Builder

Run query:

/sitecore/templates//*[@@name = '__Standard Values' and Contains(@__Masters, '{92CF4650-4D5C-4A55-9A56-651858682E6D}')]

enter image description here

PS.

Don't forget to change an ID ;)

3
  • Keep in mind that folder items may often have their insert options set directly instead of on their standard values.
    – zzzzBov
    Commented Oct 7, 2016 at 23:11
  • Nice out of the box solution with #3. Commented Oct 8, 2016 at 2:30
  • You could also combine option 1 and 3 to at least not rely on the links db. Commented Oct 23, 2017 at 21:29
8

One option is to use Sitecore Rocks to identify the items. This syntax will work if you are searching for items with an insert option set to a template with ID of {8FAD3C40-C1CC-4C4E-A3D9-F6F6BB20571D}.

select * from /sitecore/content//*[Contains(@__Masters, '{8FAD3C40-C1CC-4C4E-A3D9-F6F6BB20571D}')]  

Note that the guid must be uppercase, as Contains is a text match operator.

If this is on a production environment, you could copy the database down to a development machine, run the query, and identify the item IDs that are impacted. You can use "Export as CSV" to put these to a report.

enter image description here

1
  • 1
    As Alan notes above, my query should be modified to restrict to standard values items. Commented Oct 8, 2016 at 2:31
1

Another Option, available since Sitecore 7.0, there has been an admin tool called LINQ ScratchPad.

You would simply adjust the LINQ Query as needed (similiar to Option 2) above, except no ASPX needed:

var item = Sitecore.Data.Database.GetDatabase("master").GetItem("/sitecore/templates/Project/Playground/Page");
var itemReferrers = Sitecore.Globals.LinkDatabase.GetItemReferrers(item, true)
    .Select(link => link.GetSourceItem())
    .Where(i => i.Name.Equals("__Standard Values"));

https://community.sitecore.net/technical_blogs/b/sitecore_7_development_team/posts/sitecore-7-linqscratchpad

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.