Surendra Sharma

Surendra Sharma

Search This Blog

Friday, October 23, 2015

How to change folder structure of bucket in Sitecore



Sitecore 7 and above has feature called as item bucket.

Item bucket can store a theoretically unlimited amount of items without displaying them in content tree i.e. children’s are displayed as hidden items.

But if you want to show all hidden items then click on "View -> Buckets".

All child Items are by default displayed in tree structure of date and time format.

But what if you want to show items only according to Year wise or combination of date and time wise. How to do that?

Solution:-

Sitecore provide its config file with its every new feature. So Sitecore provides "Sitecore.Buckets.config" for bucketing. Open this file and locate below entry 

<setting name="BucketConfiguration.BucketFolderPath" value="yyyy\/MM\/dd\/HH\/mm"/>

If you want bucket by year wise then modified this configuration entry as 

<setting name="BucketConfiguration.BucketFolderPath" value="yyyy"/>

That’s it. 

But take precaution of the fact that this will create only year folder in all the buckets in content tree.

Please leave your comments or share this tip if it’s useful for you.

Wednesday, October 21, 2015

How to fix Intelligence problem in VS 2012 with MVC 4 project

I have just started working on my first MVC project and I come to know that my intelligence is not working in MVC 4 project. I didn’t found any answer for MVC 4 project on internet.

If you are facing intelligence problem in MVC 4 project, try your luck by placing yellow highlighted lines in <appSettings> section in web.config file.

  <appSettings>
    <add key="EmailReminder.FromAddress" value="name@server.net" />
 
    <add key="webpages:Version" value="2.0.0.0" />
    <add key="webpages:Enabled" value="false" />
     
  </appSettings>
 
At least it worked for me. :)

Please leave your comments or share this tip if it’s useful for you.

Tuesday, October 13, 2015

How to create custom Sitecore config file and access its key’s value in C#



I am damn sure that you must sometimes face this problem during reading, finding or modifying any entry in Sitecore web.config file.

The config file that I have contains 3950 lines. WTF how to work with such a large file. Is there any way to break it so that I can make my own settings value in other config file.

Fortunetly YES. Here is the trick.

·         Create one config file like "Sample.config" in "Website\App_Config\Include" folder and make keys entries in <settings> </settings> section as

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <settings>    
       <setting name="EnableLogin" value="true"/>
<setting name="mykeyName" value="KeyValue"/>
    </settings>
  </sitecore>
  <system.web>
  </system.web>
</configuration>

At runtime Sitecore merge all these config files and treat them as a single file and work smartly. 

And now the million dollar question, How to access it in C# code?

Simply refer GetSetting() method of Settings class as below

string strKeyValue = Sitecore.Configuration.Settings.GetSetting("mykeyName");
 
Please leave your comments or share this trick if it’s useful for you.