Friday, April 24, 2015

Sitecore SPEAK Upload Media Dialog doesn't Upload any files

It looks like that the image had been uploaded but it never finished. First of all I've found an exception in the Sitecore:

 No component for supporting the service Sitecore.Controllers.MediaController was found

It was fixed by registering the component in the code:



container.Register(Component.For(typeof(Sitecore.Controllers.MediaController))
                    .LifestylePerWebRequest());

But unfortunately it didn't help me (: That is mean my current Sitecore should be updated, Sitecore CMS 7.5 rev. 141003 Hotfix 431794-1 should fix it. But if we can't do any updates for some reason, we can switch to the old style Upload dialog.
Just go to  /App_Config/Include/Sitecore.Speak.Applications.config file and comment out the following line:

<overrideXmlControls>
   <override xmlControl="Sitecore.Shell.Applications.Media.MediaBrowser" 
          with="/sitecore/client/applications/Dialogs/SelectMediaDialog" />
</overrideXmlControls>


That is it! 

Tuesday, April 14, 2015

Injecting javascript and css to Sitecore Content Editor Page


Sometimes we need to use javascript in our custom fields, to do that we should inject them into Content Editor Page: 


    public class InjectScripts
    {
        public void Process(PipelineArgs args)
        {
            if (Sitecore.Context.ClientPage.IsEvent) return;

            HttpContext current = HttpContext.Current;
            if (current == null) return;

            Page page = current.Handler as Page;
            if (page == null) return;

            string[] strArray = {
               "/sitecore/shell/Controls/Lib/Scriptaculous/Scriptaculous.js",
               "/sitecore/shell/Controls/Lib/Scriptaculous/builder.js",
               "/sitecore/shell/Controls/Lib/Scriptaculous/effects.js",
               "/sitecore/shell/Controls/Lib/Scriptaculous/dragdrop.js",
               "/sitecore/shell/Controls/Lib/Scriptaculous/slider.js",
               "/sitecore/shell/Controls/CustomControls/CustomField/custom.js"
                                };
            foreach (string str in strArray) page.Header.Controls.Add(new LiteralControl(string.Format("", str)));
            
            page.Header.Controls.Add(new LiteralControl(""));
        }
    }

And in config file:



<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <pipelines>
      <rendercontenteditor>
        <processor patch:before="*[1]" type="CustomField.InjectScripts, CustomField">
      </processor>
     </rendercontenteditor>
    </pipelines>
  </sitecore>
</configuration>


Very Easy!