Sitecore Dictionary Items - sitecore

In the earlier versions of Sitecore there were an issue with dictionary items, if we have a CDs environment, sometimes the Dictionary.dat file may not get updated on CDs server.
1) is this issue still exist with Sitecore 8 ?
2) if yes, what is the best approach to implement custom dictionary items for my website ?

I have this issue on Sitecore 8.1 Initial Release.
To fix it you need to add on publish:end and publish:end:remote event a new handler.
This is the class :
public class DictionaryCacheClearer
{
/// <summary>
/// Clears the whole dictionary domain cache.
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="args">The <see cref="EventArgs"/> instance containing the event data.</param>
public void ClearCache(object sender, EventArgs args)
{
Translate.ResetCache();
Log.Info("Dictionary cleared", this);
}
}
On publish:end and publish:end:remote events you will have:
<event name="publish:end:remote">
<handler type="Sitecore.Publishing.HtmlCacheClearer, Sitecore.Kernel" method="ClearCache">
<sites hint="list">
<site s="1">YourSite</site>
</sites>
</handler>
<handler type="YourNameSpace.DictionaryCacheClearer, YourAssembly" method="ClearCache" />
</event>
<event name="publish:end">
<handler type="Sitecore.Publishing.HtmlCacheClearer, Sitecore.Kernel" method="ClearCache">
<sites hint="list">
<site s="1">YourSite</site>
</sites>
</handler>
<handler type="YourNameSpace.DictionaryCacheClearer, YourAssembly" method="ClearCache" />
</event>
Other fix you find it here: https://community.sitecore.net/developers/f/8/t/173

Related

Sitecore ContentSearchManager can't find index

I am using Sitecore 7.5 and I try to get bucket item's children.
I have an index "xyz" and it works when I try to get this index using:
var context = SearchManager.GetIndex("xyz").CreateSearchContext();
But I wanted to use this:
using (var context = ContentSearchManager.GetIndex("xyz").CreateSearchContext())
{
IQueryable<SearchResult> results = context.GetQueryable<SearchResult>();
}
and I receive an exception "Index xyz was not found". Why SearchManager finds this index but ContentSearchManager does not?
This is my index:
<configuration>
<indexes hint="list:AddIndex">
<index id="xyz" type="Sitecore.Search.Index, Sitecore.Kernel">
<param desc="name">$(id)</param>
<param desc="folder">xyz</param>
<Analyzer ref="search/analyzer" />
<locations hint="list:AddCrawler">
<web-pomoc type="Website.Classes.Search.BasicDatabaseCrawler, Website">
<Database>web</Database>
<Root>/sitecore/content/Shared/Kolekcje/Vod/Catchup-VOD</Root>
<templates hint="list:IncludeTemplate">
<entry>{DA757C92-A4CC-468F-BC22-AD347C8C4C9C}</entry>
</templates>
</web-pomoc>
</locat
</indexes>
</configuration>
Edit:
I changed my index and now it looks like this:
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<contentSearch>
<configuration type="Sitecore.ContentSearch.ContentSearchConfiguration, Sitecore.ContentSearch">
<indexes hint="list:AddIndex">
<index id="catchup_search" type="Sitecore.ContentSearch.LuceneProvider.LuceneIndex, Sitecore.ContentSearch.LuceneProvider">
<param desc="name">$(id)</param>
<param desc="folder">$(id)</param>
<!-- This initializes index property store. Id has to be set to the index id -->
<param desc="propertyStore" ref="contentSearch/indexConfigurations/databasePropertyStore" param1="$(id)" />
<configuration type=”Sitecore.ContentSearch.LuceneProvider.LuceneIndexConfiguration, Sitecore.ContentSearch.LuceneProvider”>
<indexAllFields>false</indexAllFields>
<initializeOnAdd>true</initializeOnAdd>
<analyzer ref=”contentSearch/indexConfigurations/defaultLuceneIndexConfiguration/analyzer” />
<include hint="list:IncludeTemplate">
<catchup_entry>{DA757C92-A4CC-468F-BC22-AD347C8C4C9C}</catchup_entry>
</include>
</configuration>
<strategies hint="list:AddStrategy">
<!-- NOTE: order of these is controls the execution order -->
<strategy ref="contentSearch/indexConfigurations/indexUpdateStrategies/onPublishEndAsync" />
</strategies>
<commitPolicyExecutor type="Sitecore.ContentSearch.CommitPolicyExecutor, Sitecore.ContentSearch">
<policies hint="list:AddCommitPolicy">
<policy type="Sitecore.ContentSearch.TimeIntervalCommitPolicy, Sitecore.ContentSearch" />
</policies>
</commitPolicyExecutor>
<locations hint="list:AddCrawler">
<crawler type="Sitecore.ContentSearch.SitecoreItemCrawler, Sitecore.ContentSearch">
<Database>web</Database>
<Root>/sitecore/content/xyz/avc</Root>
</crawler>
</locations>
</index>
</indexes>
</configuration>
</contentSearch>
</sitecore>
</configuration>
Now it appears in Index manager, but when I rebuild it, 0 items is processed.
Change the type from Sitecore.Search.Index, Sitecore.Kernel to Sitecore.ContentSearch.LuceneProvider.LuceneIndex, Sitecore.ContentSearch.LuceneProvider
SearchManager.GetIndex("xyz").CreateSearchContext() - makes use of the IndexSearchContext
while
ContentSearchManager.GetIndex("xyz").CreateSearchContext() - makes use of SitecoreContentSearch
Sitecore make use of the SitecoreContentSearch to rebuild the indexes.
Thanks
Your index definition is wrong
You need to use something like:
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<contentSearch>
<configuration type="Sitecore.ContentSearch.ContentSearchConfiguration, Sitecore.ContentSearch">
<indexes hint="list:AddIndex">
<index id="sitecore_web_index" type="Sitecore.ContentSearch.LuceneProvider.LuceneIndex, Sitecore.ContentSearch.LuceneProvider">
<param desc="name">$(id)</param>
<param desc="folder">$(id)</param>
...
</index>
</indexes>
</configuration>
</contentSearch>
Please check default index definition from Sitecore 7.5
After you add index configuration file please check if your index appear in IndexManager:

Sitecore Patch - Add website

I'm trying to add site name on list of sites so that HTML cache gets cleared on publish:end:remote event.
<event name="publish:end:remote">
<handler type="Sitecore.Publishing.HtmlCacheClearer, Sitecore.Kernel" method="ClearCache">
<sites hint="list">
<site patch:after="*[#site]">mysite</site>
</sites>
</handler>
<handler type="Sitecore.Publishing.RenderingParametersCacheClearer, Sitecore.Kernel" method="ClearCache"/>
</event>
However it isn't working as expected. I did googling and didn't find anything on how we can patch before or after an element. Most of the examples are on/before attribute etc.
Thanks.
If you want to patch a node without attributes, you can select the text() of the node to compair. before or after. see this Example:
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<events timingLevel="custom">
<event name="publish:end:remote">
<handler type="Sitecore.Publishing.HtmlCacheClearer, Sitecore.Kernel" method="ClearCache">
<sites>
<site patch:before="site[./text()='website']">plop3</site>
</sites>
</handler>
</event>
</events>
</sitecore>
</configuration>
A different approach to your issue.
With a patch delete you can clear the list and build your list from scratch.
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<events timingLevel="custom">
<event name="publish:end:remote">
<handler type="Sitecore.Publishing.HtmlCacheClearer, Sitecore.Kernel" method="ClearCache">
<sites hint="list">
<patch:delete />
</sites>
<sites hint="list">
<site>website</site>
<site>anotherwebsite</site>
</sites>
</handler>
</event>
</events>
</sitecore>
</configuration>
You don't need to use any patch:delete or patch:instead. You just need to add name attribute to your new <site> tags so Sitecore will treat them as a separate site definitions.
Here is some further explanation: Config patching system for the external config files
Create App_config\Include\My.Site.Definition.config file with content:
<sitecore>
<sites>
<site name="mysite" patch:before="site[#name='website']"
... />
</sites>
<events>
<event name="publish:end">
<handler type="Sitecore.Publishing.HtmlCacheClearer, Sitecore.Kernel" method="ClearCache">
<sites hint="list">
<site name="mysite">mysite</site>
</sites>
</handler>
</event>
<event name="publish:end:remote">
<handler type="Sitecore.Publishing.HtmlCacheClearer, Sitecore.Kernel" method="ClearCache">
<sites hint="list">
<site name="mysite">mysite</site>
</sites>
</handler>
</event>
</events>
</sitecore>
The other option would be to use some other tags instead of <site> tag, cause when the parent tag contains hint="list" attribute, it treats all the children tags as items for that list. You would need to make sure that every tag is unique. You can use it like that:
<event name="publish:end:remote">
<handler type="Sitecore.Publishing.HtmlCacheClearer, Sitecore.Kernel" method="ClearCache">
<sites hint="list">
<site1>mysite</site1>
<othersite>othersite</othersite>
</sites>
</handler>
</event>
You don't have to patch list of sites. You need to add all your websites one by one.
<event name="publish:end:remote">
<handler type="Sitecore.Publishing.HtmlCacheClearer, Sitecore.Kernel" method="ClearCache">
<sites hint="list">
<site>SiteOne</site>
<site>Sitetwo</site>
...
<site>SiteN</site>
</sites>
</handler>
</event>
This has been already answered but adding to the answer above- while patching the sites you don't need to add other element attributes but only the ones you are patching.
<sitecore>
<events>
<!-- Html Cache clear on publish events -->
<!-- Force FULL cache clear on publish-->
<event name="publish:end">
<handler>
<sites>
<site name="customSite">customSite</site>
</sites>
</handler>
</event>
<!-- Html Cache clear on publish events -->
<!-- Force FULL cache clear on publish-->
<event name="publish:end:remote">
<handler>
<sites>
<site name="customSite">customSite</site>
</sites>
</handler>
</event>
</events>

Creating an entry in Windows Event Viewer

I want to create a new entry under Applications and Services Log in Windows Event Viewer for my application. I used ECManGEN tool to generate the manifest and after doing the necessary steps linked it with my project. It works.. However, a folder is created with the provider name(MyTrial2 in below figure) and the channel comes under that folder. Is it possible to have only the channel without the folder?(As Internet Explorer, Microsoft Office Alerts, etc in the figure)
EDIT - Added the generated Manifest file
<?xml version="1.0" encoding="UTF-16"?>
<instrumentationManifest xsi:schemaLocation="http://schemas.microsoft.com/win/2004/08/events eventman.xsd" xmlns="http://schemas.microsoft.com/win/2004/08/events" xmlns:win="http://manifests.microsoft.com/win/2004/08/windows/events" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:trace="http://schemas.microsoft.com/win/2004/08/events/trace">
<instrumentation>
<events>
<provider name="MyTrial2" guid="{90DDCC4A-2F8A-4B57-85AF-5401E678708A}" symbol="MyTrial2" resourceFileName="E:\MyEventTrial\MyEventTrial\Debug\MyEventTrial.exe" messageFileName="E:\MyEventTrial\MyEventTrial\Debug\MyEventTrial.exe">
<events>
<event symbol="EvenEvent2" value="1" version="0" channel="TrialChannel2" level="win:Informational" message="$(string.MyTrial.event.1.message)">
</event>
<event symbol="OddEvent2" value="2" version="0" channel="TrialChannel2" level="win:Informational" message="$(string.MyTrial.event.2.message)">
</event>
<event symbol="ErrorEvent2" value="3" version="0" channel="TrialChannel2" level="win:Error" message="$(string.MyTrial.event.3.message)">
</event>
</events>
<levels>
</levels>
<channels>
<channel name="TrialChannel2" chid="TrialChannel2" symbol="TrialChannel2" type="Admin" enabled="true">
</channel>
</channels>
</provider>
</events>
</instrumentation>
</instrumentationManifest>

Adding an event handler to a web.config gives error: configuration file is not well-formed XML

Per this blog post, I am trying to add an event to my Sitecore web.config file, and do exactly what he is doing. This is exactly how I have it in my file.
<events timingLevel="custom">
...
<event name="item:added">
<handler type="BenefitVault.Core.Helpers.SitecoreEvents, BenefitVault" method="OnItemAdded" patch:after="processor[#type='Sitecore.Data.Fields.ItemEventHandler, Sitecore.Kernel']" />
</event>
...
</events>
However, when I try to hit my local site, I get the error below. It looks like a syntax error, but I'm not seeing the problem. Any ideas?
If you've added this entry into directly into web.config then you do not need the patch declaration, just add it without, e.g:
<events timingLevel="custom">
...
<event name="item:added">
<handler type="BenefitVault.Core.Helpers.SitecoreEvents, BenefitVault" method="OnItemAdded" />
</event>
...
</events>
But you should avoid making changes to the section of config directly, it will hinder you when trying to upgrade and mean you have to try to figure out what changes have been made. Instead you should use a patch include file, which is what the original article you linked to is referring to (and the reason it is failing when you modify directly)
Create a new config file under /App_Config/Include folder, (optionally create it under /App_Config/Include/zProjectName to really ensure it gets patched in last)
/App_Config/Include/zMyProject/EventHandlers.config
<?xml version="1.0"?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<events timingLevel="custom">
<event name="item:added">
<handler type="BenefitVault.Core.Helpers.SitecoreEvents, BenefitVault" method="OnItemAdded"
patch:after="processor[#type='Sitecore.Data.Fields.ItemEventHandler, Sitecore.Kernel']" />
</event>
</events>
</sitecore>
</configuration>

Sitecore Patching

I want to insert some new nodes in an existing node of a Sitecore configuration file.
How do I patch the default behavior of:
<event name="publish:end">
<handler type="Sitecore.Publishing.HtmlCacheClearer, Sitecore.Kernel" method="ClearCache">
<sites hint="list">
<site>website</site>
</sites>
</handler>
</event>
with:
<event name="publish:end">
<handler type="Sitecore.Publishing.HtmlCacheClearer, Sitecore.Kernel" method="ClearCache">
<sites hint="list">
<site>english</site>
<site>chinese</site>
<site>german</site>
<site>spanish</site>
<site>french</site>
<site>italian</site>
<site>japanese</site>
<site>portuguese</site>
<site>russian</site>
<site>website</site>
</sites>
</handler>
</event>
<event name="publish:end">
<handler type="Sitecore.Publishing.HtmlCacheClearer, Sitecore.Kernel" method="ClearCache">
<sites hint="list">
<patch:delete />
</sites>
<sites hint="list">
<site>english</site>
<site>chinese</site>
<site>german</site>
<site>spanish</site>
<site>french</site>
<site>italian</site>
<site>japanese</site>
<site>portuguese</site>
<site>russian</site>
<site>website</site>
</sites>
</handler>
</event>