Last active
August 29, 2015 14:25
-
-
Save michaellwest/b15ce61bdfcaa5b5ac1b to your computer and use it in GitHub Desktop.
Sitecore patch configuration to add _basetemplates to the default Lucene index. Includes sample report.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$index="sitecore_master_index" | |
$props = @{ | |
Parameters = @( | |
@{ Name="Info"; Title="Index"; Value="The report will be based on $($index)."; editor="info" }, | |
@{ | |
Name="searchBaseTemplate" | |
Value="" | |
Title="Base Template" | |
Tooltip="Index the _basetemplates field as shown here on <a href='https://github.com/SitecorePowerShell/Console/issues/424' target='_blank'>Github</a>." | |
Placeholder='{7B76036F5E-CBCE-46D1-AF0A-4143F9B557AA}' | |
Mandatory=$true | |
} | |
) | |
Title = "Base Template Report" | |
Description = "Choose the criteria for the report." | |
Width = 450 | |
Height = 300 | |
ShowHints = $true | |
} | |
$result = Read-Variable @props | |
if($result -eq "cancel"){ | |
exit | |
} | |
$database = Find-Item -Index $index -First 1 | % { $_.DatabaseName } | |
$root = Get-Item -Path (@{$true="$($database):\content\home"; $false="$($database):\content"}[(Test-Path -Path "$($database):\content\home")]) | |
$data = @{ | |
Index = $index | |
Criteria = @(@{ | |
Filter = "DescendantOf" | |
Value = $root | |
}) | |
} | |
if($searchBaseTemplate -and [Sitecore.Data.ID]::IsID($searchBaseTemplate)) { | |
$data.Criteria += @{ | |
Field = "_basetemplates" | |
Filter = "Contains" | |
Value = ([Sitecore.Data.ID]::Parse($searchBaseTemplate).ToShortID().ToString().ToLowerInvariant()) | |
} | |
} | |
Find-Item @data | Show-ListView -Property Name, Language, Version, Url, Path -Title "Base Template Report" | |
Close-Window |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Use with Sitecore 7.0 to 7.1 --> | |
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/"> | |
<sitecore> | |
<contentSearch> | |
<configuration> | |
<defaultIndexConfiguration> | |
<fields hint="raw:AddComputedIndexField"> | |
<field fieldName="_basetemplates" storageType="yes" indexType="untokenized">Sitecore.ContentSearch.ComputedFields.AllTemplates, Sitecore.ContentSearch</field> | |
</fields> | |
</defaultIndexConfiguration> | |
</configuration> | |
</contentSearch> | |
</sitecore> | |
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Use with Sitecore 7.2 and 8 --> | |
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/"> | |
<sitecore> | |
<contentSearch> | |
<indexConfigurations> | |
<defaultLuceneIndexConfiguration type="Sitecore.ContentSearch.LuceneProvider.LuceneIndexConfiguration, Sitecore.ContentSearch.LuceneProvider"> | |
<fields hint="raw:AddComputedIndexField"> | |
<field fieldName="_basetemplates" storageType="yes" indexType="untokenized">Sitecore.ContentSearch.ComputedFields.AllTemplates, Sitecore.ContentSearch</field> | |
</fields> | |
</defaultLuceneIndexConfiguration> | |
</indexConfigurations> | |
</contentSearch> | |
</sitecore> | |
</configuration> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment