Monday, 30 November 2015

Force Download of PDF in Sitecore

Make sure to have ForceDownload as true and disable the Range Retrival using below setting if needed.

<mediaType name="PDF file" extensions="pdf">  
  <mimeType>application/pdf</mimeType>  
  <forceDownload>true</forceDownload>  
</mediaType>  


<setting name="Media.EnableRangeRetrievalRequest" value="false"/>

Friday, 27 November 2015

Can we do swap of CORE for Given Sitecore Index

Yes we can have two cores for given sitecore index and can be swapped..


When Sitecore is configured to use 2 cores for particular index, it will use the primary one for retrieving search results. Every time you execute rebuild of the index, secondary core will be rebuilt and after the rebuild, cores will be switched - the rebuilt core will become new primary core, and the old primary core will become secondary core now.


Please refer the below url in order to have detailed understanding of the same.


http://www.skillcore.net/sitecore/using-switchonrebuildsolrsearchindex-solr-provider-for-sitecore



Thursday, 19 November 2015

Alias not working when changed

How to check Alias is active 

Settings.AliasesActive

How to check if alias exist

Database database = Context.Database;  
database.Aliases.Exists


Monday, 16 November 2015

Descendant and Ancestor axes are disabled. Set FastQueryDescendantsDisabled setting to false to enable these axes.

Suddenly this morning I started getting error

Descendant and Ancestor axes are disabled. Set FastQueryDescendantsDisabled setting to false to enable these axes.

When researched found there is a setting in web.config 

      <!-- FAST QUERY DESCENDANTS DISABLED
           Determines whether ability to select items through Ancestors/Descendants axes should be disabled in fast query.
           Default value: false
      -->
      <setting name="FastQueryDescendantsDisabled" value="false" />


Surprised that this setting has not been changed ; to invetigate further i searched FastQueryDescendantsDisabled invetigate whole root solution folder..

Then I found one more place where it was true..changed and life back to normal,

               Website\App_Config\Include\Sitecore.Publishing.Optimizations.config 



Please note 


As per sitecore fast query cheat sheet whenever we change this we should clean up the databases.


Note
If the FastQueryDescendantsDisabled setting, in the web.config file, is set to true and then changed back
to false, you must rebuild the Descendents table.
To rebuild the Descendents table, click Sitecore, Control Panel, Databases, Clean Up Database and run
the Clean Up Database wizard.




Monday, 2 November 2015

Thursday, 29 October 2015

How to remove item's Workflow& WorkflowState programmatically?

using ( new SecurityDisabler() )
{
Item.Editing.BeginEdit();

Item["__workflow"] = string.Empty;
Item["__workflow state"] = string.Empty;
Item["__lock"] = "<r />";
Item["__default workflow"] = string.Empty;

Sitecore.Context.Item.Editing.EndEdit();
}

Wednesday, 28 October 2015

How to get The Home Item of the Context Site

Sitecore.Sites.SiteContext contextSite = Sitecore.Context.Site; Sitecore.Data.Items.Item home = Sitecore.Context.Database.GetItem(contextSite.StartPath);

How to compare two table data in sql server

 SELECT * FROM tbl_NewData
    EXCEPT

 SELECT * FROM tbl_OldData  

Import Data from excel Sheet


 EXEC sp_configure 'Show Advanced Options', 1
RECONFIGURE


EXEC sp_configure 'Ad Hoc Distributed Queries', 1
RECONFIGURE


EXEC sp_MSSet_oledb_prop N'Microsoft.ACE.OLEDB.12.0', N'AllowInProcess', 1


EXEC sp_MSSet_oledb_prop N'Microsoft.ACE.OLEDB.12.0', N'DynamicParameters', 1



USE SLBSOFTWARE

select * FROM   OPENROWSET('Microsoft.ACE.OLEDB.12.0',
'Excel 12.0 Xml;HDR=YES;Database=D:\DataMigrationFiles\New Data.xlsx',
'SELECT * FROM [Sheet2$]')




Please note we need to run the SSMS with Super user.



Tuesday, 20 October 2015

How to disable the Remember me checkbox on the login page

  <!--  LOGIN DISABLE REMEMBER ME
            If true, Sitecore disables the "Remember me" checkbox on the login page.
            Default: false
      -->
      <setting name="Login.DisableRememberMe" value="true" />

How can we Turn off Auto Complete of Username in the Login Page

  <!--  LOGIN DISABLE AUTOCOMPLETE
            If true, an autocomplete="off" attribute is added on the Sitecore login forms on the /sitecore/login/default.aspx and 
            /sitecore/admin/login.aspx pages. This is useful, for example, if you don't want user names to be disclosed when editors
            log into Sitecore on shared/public computers.
            Default value: false
      -->
      <setting name="Login.DisableAutoComplete" value="false" />

How to prevent Cross-Frame Scripting


        <add name="X-Frame-Options" value="SAMEORIGIN" />

Can we encrypt the connection string in sitecore

http://blog.istern.dk/2014/05/01/encrypting-and-securing-your-sitecore-connenction-strings/

https://mickeyrahman.wordpress.com/2014/07/15/securing-sitecore-configuration-files-with-server-side-encryption/

Custom item url for Item Bucketing

https://adeneys.wordpress.com/2013/07/19/item-buckets-and-urls/

Monday, 19 October 2015

how to not index all sitecore item in sitecore search

There is setting called Root in Index Definition in "Sitecore.ContentSearch.Solr.Indexes.config"
 file.

Here we can mentioned the root of our site to exclude the unwanted index..

 <Root>/sitecore/content/your/site/root</Root>

Monday, 5 October 2015

Why not to use Sitecore Internal Links as Field Type in Sitecore Data Template

internal Links store references by item path rather then ID..That why we should not use Internal Links.
Use drop tree as back up.





Wednesday, 9 September 2015

Sitecore Gutter

http://www.kasaku.co.uk/2014/12/08/creating-a-custom-gutter-validator/

We can have custom gutter can use this in order to write custom validatios..

Tuesday, 8 September 2015

Sitecore Rich Text Not Working

We were getting javascript error while adding data on Sitecore Rich text editor.


The issue was content was not good.

Wednesday, 2 September 2015

Developer Assistant

https://visualstudiogallery.msdn.microsoft.com/a1166718-a2d9-4a48-a5fd-504ff4ad1b65


Developer Assistant puts millions of code snippets and code sample projects at your fingertips while you are coding in Visual Studio.

Thursday, 13 August 2015

How can I ensure the rendering Properties is always opened when I add rendering to Item

The "Open Properties After Add" field allows you to choose if the component properties (datasource, caching, params etc.) windows will be opened automatically when a content editor adds a sublayout to a page. It has values of "Default", "Yes" and "No".


How Can I export Mime Types from One machine to other Machine

 The Mime type are stored on below files.. Copy Paste from one machine to other may help


c:\windows\system32\inetsrv\metabase.xml

 c:\windows\system32\inetsrv\config\applicationhost.config

Wednesday, 12 August 2015

Viewstate uses which classes in order to save control state

Manages the view state of ASP.NET server controls, including pages. This class cannot be inherited.


System.Object 
  System.Web.UI.StateBag

Is duration compulsary in OutputCache

Yes
 
If you will not pass you will get Run time parser error..
 
 
 [OutputCache( VaryByParam = "None")]
 
Will Throw run time error... 

Tuesday, 11 August 2015

How to disable Indexing in sitecore

<setting name="Indexing.Enabled" value="false" />

Sitecore.Configuration.Settings.Indexing.Enabled = false;
 
This is used in sitecore as
 
            public static bool Enabled
            {
                get
                {
                    return Settings.Indexing.enabled;
                }
                set
                {
                    Settings.Indexing.enabled = value;
                }
            } 
 
 
Also 
 
    // How to pause indexing in Sitecore 7.0 Update-1 (rev130810) and later
    IndexCustodian.PauseIndexing();
    // Do a lot of item updates
    // Enable indexing again. Might be a good idea to also rebuild all indexes.
    IndexCustodian.ResumeIndexing();
 
 

Thursday, 6 August 2015

Image compression using Dianoga

https://github.com/kamsar/Dianoga

I installed using Nuget


https://www.nuget.org/packages/Dianoga/

PM> Install-Package Dianoga

Thursday, 30 July 2015

Fast Query Observation


  • Sorting is not allowed
  • Fast Query does not support Functions 
  • Fast query does not search standard values
  • Fast query does not support subquery 
  • ; is seperator for multiple query

How to redirect Permanent to given Url

   private void RedirectPermanent(string url)
        {
            HttpContext current = HttpContext.Current;
            current.Response.Clear();
            current.Response.StatusCode = 301;
            current.Response.RedirectLocation = url;
            current.Response.AddHeader("X-SFUM-Redirect", "true");
            current.Response.End();
        }

Friday, 17 July 2015

How to clear all values in dropdown

var ddl = document.getElementById("ddlKey");

ddl.options.length=0;

JSON.stringify()

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify


The JSON.stringify() method converts a JavaScript value to a JSON string..

Tuesday, 30 June 2015

What is the Maximum Limit for Sitecore Item

The maximum length of an item name is configurable and by default it is set as 100.

      <!--  MAX ITEM NAME
            Specifies the maximum length of an item name.
            Default value: 100
      -->
      <setting name="MaxItemNameLength" value="100" />

Friday, 26 June 2015

Sitecore query analyzer in returning wrong Count

I was trying to get count of number of subitems within my ItemPath using below query select count(ItemPath/* ) but this query is returning always 500 though the number of items
select count(ItemPath/* ) but this query is returning always 500 though the number of items
Sitecore climber  suggest to check below properties 

   <!--  Query.MaxItems
            Specifies the max number of items in a query result set.
            If the number is 0, all items are returned. This may affect system performance, if a
            large query result is returned.
            This also controls the number of items in Lookup, Multilist and Valuelookup fields.
            Default value: 100
      -->
      <setting name="Query.MaxItems" value="500" />

It worked

https://community.sitecore.net/developers/f/8/p/512/1955#1955

Monday, 22 June 2015

Delete Sub Items Sitecore

All you have to do is click on the parent item and  then click on the Home tab in the Ribbon, and then click on the Delete drop-down in the Operations 


You can also Use Sitecore Rocks & Select Multiple item using ctrl

We can also use Sitecore Query Analyzer

                    Delete  From /sitecore/content/.../ItemTobedeleted/*


What about using Powershell Module.  :) 

Friday, 19 June 2015

Sitecore Query :: How to Handle Field with Space

select @#FIELD NAME# from /sitecore/content/Home

Assign value to Multilist Field to given sitecore item

                                MultilistField mf = myitem.Fields["Field Name"];
                              string query = String.Format(CultureInfo.InvariantCulture, "fast:/sitecore/content/....//*[@Name='{0}']", searchText);

                                            Item reference = master.SelectSingleItem(query);
                                            if (reference != null)
                                            {
                                                mf.Add(reference.ID.ToString());
                                            }

Assign the DateTime Field Using Sitecore API

var date = Datetime.Now;
                                if (!string.IsNullOrEmpty(date))
                                {
                                    var dateTime = DateTime.Parse(date, CultureInfo.InvariantCulture);
                                    var isoDate = DateUtil.ToIsoDate(dateTime);
                                    Item["Date"] = isoDate;
                                }


More Info

http://getfishtank.ca/blog/using-date-and-datetime-fields-in-sitecore

Tuesday, 16 June 2015

Remove ~ from media url sitecore

As said IIS need some elevated privileges in order to cater

 /~/media prefix 


So we remove this by below line of code.

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <settings>
      
      <setting name="Media.MediaLinkPrefix">
        <patch:attribute name="value">-/media</patch:attribute>
      </setting>
    </settings>
    <customHandlers>
      <handler trigger="-/media/" handler="sitecore_media.ashx"/>
    </customHandlers>
  </sitecore>
</configuration>


http://www.sitecore.net/learn/blogs/technical-blogs/john-west-sitecore-blog/posts/2012/12/sitecore-idiosyncrasies-media-urls.aspx

Disable the Upload watcher sitecore

Upload watcher automatically creates items in the Media section for files in /Website/upload folder, which may present a security risk if this functionality is not used.

Disabling Upload watcher  ensures that you can only upload files from within the Sitecore client and have control over the files that are uploaded  

When Upload Watcher is disabled, files that are placed in the /upload folder are not automatically
uploaded to the Media Library



IIS7
 <system.webServer>
 <modules>
 <remove name="ScriptModule"/>
 <add type="Sitecore.Nexus.Web.HttpModule,Sitecore.Nexus" name="SitecoreHttpModule"/>
 <add type="Sitecore.Resources.Media.UploadWatcher, Sitecore.Kernel"
name="SitecoreUploadWatcher"/>


IIS6
 <httpModules>
 <add type="Sitecore.Nexus.Web.HttpModule,Sitecore.Nexus" name="SitecoreHttpModule"/>
 <add type="Sitecore.Resources.Media.UploadWatcher, Sitecore.Kernel"
name="SitecoreUploadWatcher"/>



More detials

https://sdn.sitecore.net/upload/sitecore6/62/sitecore_security_hardening_guide-usletter.pdf




Wednesday, 13 May 2015

What is the Default Data Source for Rendering

 If you do not pass a data source item to a rendering, the context item is the default data source item for that rendering.

John West.

Wednesday, 6 May 2015

Rebuild Link Database

Navigate --> Links is not working fine .. the link was not reflecting the referenced item.

We need to rebuild the link Database.

Control Panel --> Database --> Rebuild the Link Database


SITECORE MULTILOG DOWNLOADER

https://marketplace.sitecore.net/Modules/Sitecore_MultiLog_Downloader.aspx?sc_lang=en

Monday, 4 May 2015

How to set and refresh the Drop down list value using jquery

$('#elementKey').find('option:contains("Defaultvalue")').attr("selected"true);
$('#elementKey').find('option:contains("Defaultvalue")').attr("selected"true);

closedxml ClosedXML - The easy way to OpenXML

https://closedxml.codeplex.com/

crossdomain.xml

http://www.ookla.com/support/a21097566/What-is-crossdomain-xml-and-why-do-I-need-it

http://www.devtoolshed.com/explanation-cross-domain-and-client-access-policy-files-silverlight

Tuesday, 21 April 2015

DownThemAll!

DownThemAll! (DTA) is a download manager/accelerator extension for Mozilla Firefox, licensed under the GPL. It can pause and restart supporting downloads at any time, without losing data, and enables users to download all the links, images or embedded objects contained in a webpage. Both HTTP and FTP protocols are supported.[4]

http://en.wikipedia.org/wiki/DownThemAll

Wednesday, 15 April 2015

Custom Full Rich Text Editor in Sitecore

 <setting name="HtmlEditor.DefaultProfile" value="/sitecore/system/Settings/Html Editor Profiles/Rich Text Default" />

Change this to


 <setting name="HtmlEditor.DefaultProfile" value="/sitecore/system/Settings/Html Editor Profiles/Rich Text Full" />


Grammarly Spell Checker & Grammar Correction tool

Disable web Editing in Sitecore : Page Editor Mode

if  we want the field to be non editable in Page Editor mode



<sc:Text Field="Your feild " DisableWebEditing="true" runat="server" />


FieldRenderer.Render(HeadingType, "Your Feild", "disable-web-editing=true");

@Html.Sitecore().Field("Field Name", new { DisableWebEdit = true })


Tuesday, 14 April 2015

Customize the Code Analysis Dictionary


CA1704: Identifiers should be spelled correctly


https://msdn.microsoft.com/en-us/library/bb514188.aspx

Wednesday, 8 April 2015

Set Reminder for Sitecore content

If you have some promotional content Item .. Set Reminder on that Item in order to remove the item ..Helps a lot

Wednesday, 1 April 2015

Sql Server 2012 Getting ::: Operating system error 5: "5(Access is denied.)"

I was getting the below Error while attaching .mdf file in to Database

Unable to open the physical file "". Operating system error 5: "5(Access is denied.)". (Microsoft SQL Server, Error: 5120)


I have granted the full control to folder containing the file..

This resolved my issue..

More info

https://dbamohsin.wordpress.com/2009/06/03/attaching-database-unable-to-open-physical-file-access-is-denied/


Thursday, 26 March 2015

Sitecore Market Place :: Module We Blog

https://marketplace.sitecore.net/en/Modules/WeBlog.aspx

https://github.com/WeTeam/WeBlog/wiki/Sites-Running-WeBlog

http://sdn.sitecore.net/SDN5/Forum/ShowForum.aspx?ForumID=30

Tuesday, 24 March 2015

TFS Basic Series Part 1 : How to Use Label in TFS 2013

Click File --> Source Control -->Advanced --> Apply label

We need to Provide label Name , Comment, Path and version..

We can also provide label by command line


  1. Click Start, click All Programs, point to Microsoft Visual Studio 2005, point to Visual Studio Tools, and then click Visual Studio 2005 Command Prompt.
  2. Type cd path, where path is the directory that contains the applicable workspace.
  3. Type tf label mylabel . /r.
  4. Attaches the "mylabel" label to the workspace version of the "path" folder and all the files and folders it contains.

We can find the label by

Click File --> Source Control -->Find Label.

We can create branch whenever needed on top of given Label..

Build server automatically label for each build.

We can have multiple label applied to same version of file.

Applying label is as good as creating branch..Labelling should be done quite often while branching to be done rarely..

As a best practices branching should be done only to do patching to release.

Sources:
https://msdn.microsoft.com/en-us/library/ms181440(VS.80).aspx

Sitecore Courier Set Up

Downloaded the package using

https://marketplace.sitecore.net/en/Modules/Sitecore_Courier.aspx

Login to sitecore using Desktop Mode

Installed the Downloaded Package

Now U can access the Courier using    ~/sitecore/admin/PackageGenerationWizard.aspx

Oh I got the Error

Object reference not set to an instance of an object.


[NullReferenceException: Object reference not set to an instance of an object.]
   Sitecore.Update.Utils.ConfigurationUtils.GetConfiguration(ConfigReader reader) +207
   Sitecore.Update.Utils.ConfigurationUtils.CreateObject(String configPath, String[] parameters, ConfigReader reader) +134
   Sitecore.Update.Configuration.Factory.GetSourceDataManager() +43
   Sitecore.Courier.DiffGenerator.GetDiffCommands(String sourcePath, String targetPath) in C:\Users\Pro\Documents\My Dropbox\Courier\Sitecore.Courier\Sitecore.Courier\DIffGenerator.cs:23
   Sitecore.Courier.WebRunner.PackageGenerationWizard.Analyze_Click(Object sender, EventArgs e) in C:\Users\Pro\Documents\My Dropbox\Courier\Sitecore.Courier\Sitecore.Courier.WebRunner\PackageGenerationWizard.aspx.cs:35
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +154
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3803


The issue is that I  have not done the config setting..

 <section name="sitecorediff" type="Sitecore.Update.Configuration.ConfigReader, Sitecore.Update"/>


  <sitecorediff>
    <commandfilters>
      <filter id="changedFieldsFilter" mode="on" type="Sitecore.Update.Commands.Filters.ChangedFieldsFilter, Sitecore.Update">
        <fields hint="list">
          <field>__Created</field>
          <field>{5DD74568-4D4B-44C1-B513-0AF5F4CDA34F}</field>
          <field>__Revision</field>
          <field>__Updated</field>
          <field>__Updated by</field>
        </fields>
      </filter>
    </commandfilters>
    <dataproviders>
      <dataprovider id="filesystemmain" type="Sitecore.Update.Data.Providers.FileSystemProvider, Sitecore.Update">
        <param>$(id)</param>
      </dataprovider>
      <dataprovider id="snapshotprovider" type="Sitecore.Update.Data.Providers.SnapShotProvider, Sitecore.Update">
        <param>$(id)</param>
      </dataprovider>
    </dataproviders>

    <source type="Sitecore.Update.Data.DataManager, Sitecore.Update">
      <param>source</param>
    </source>

    <target type="Sitecore.Update.Data.DataManager, Sitecore.Update">
      <param>target</param>
    </target>
  </sitecorediff>




I was now able to analyse the changes ... But when I clicked "Download Package" I got the "

HTTP Error 404.3 - Not Found" error e"



I then added the Mime type for .update .. I dont know the correct mime type .. So I tried my luck as

.update  &  application/update..

It worked for me..

I changed some items and then serialized them in to other folder.. and then I generate the package which can be installed back on the server.