Friday, 29 December 2017

How to increase performance of Sitecore Application?

It's one more great year, thank you Sitecore. Today going to write a blog post related to Speedup Sitecore Instance.

"Opportunities(Users) have no patience for websites with poor load speeds"- It's True.

sitecore-application-performance


So to increase performance of normal web application, below keys are very useful:
  • Caching
  • Minimizing http request (Bundling CSS/JS)
  • Use CSS sprites to load all icons
  • Optimize Image Compression

Let's start with for Sitecore Instance in details:

Here noted down some points, hope will help.

1. Caching (HTML Cache/ Item Cache/ Data Cache/ Prefetch Cache)

Always use HTML Caching, if possible then make all the view rendering cachable.

To increase startup of application:
Should work with Prefetch cache, because item's data are already fetched from database to prefetch cache.
now let's jump to ~/app_config/prefetch/ and customize by

How much will be cache size for:
a. can limit cache size of item
b. can limit cache size of children

Which item will be cachable will listed down:
c. can preload template that most frequent pages are using
like: master components/pages based templates (header/footer)
d. can preload item
like: Home (most visited page for any site)
e. can preload child item
like: Immediate child of Home

2. Sitecore Client:

Always give limited permission to Content Author
And make sure, have no permission for Site Publish
Should have only incremental/smart publish permission
Content expiration should be enable in IIS
Don't show standard fields in Content editor
limit number of child for Parent Item to 100

3. Database:

Make sure to completely truncate tables(listed below), before publishing website
History
PublishQueue
EventQueue

4. Monitor Sitecore logs files continuously

5. Disable Search index, if not using

6. Check is there any scheduled task running in background (possibly custom task may running, disable if unwanted).

7. Use Bundling for minification of JS/CSS to improve request load time.

8. Since Fast Query and Axes.GetDescendants() both are not cachable, so try to less use.


This Year Boosting,

Merry Christmas๐ŸŽ„๐ŸŽ…๐Ÿ‘
Happy New Year✌๐ŸŽˆ๐Ÿป

Sunday, 24 December 2017

Guideline: Sitecore 9 Setup on local Machine


  • Since already prepared a ppt related to this at


     

and also uploaded updated version of ppt also attached with github repository

https://github.com/sitecorelibraries/sitecorelibraries.github.io/blob/master/Documentation/Guidlines_Sitecore9_Installation._v1.1.pptx

Please let me know if facing any issue.

Have a Good day!!!

Saturday, 23 December 2017

Dynamic Multi-Level Menu: Sitecore

multi-level-menu-sitecore
Dynamic Multi-level Menu

Requirements:
Here's a requirement where someone asking to create multi-level menu, but the condition is in future client can add more submenu level. It means unlimited level of navigation.

Resources:
With the help of controller will able to get the list of navigation item from sitecore content tree. And if in future, if someone going to add more navigation item then no need to change code logic.

Implementation:
Now at the time of rendering, we wanted to list all the navigation item with less-code smartly. Previously we were listing navitem like:
<div>
   <ul>
     @if (Model?.Items != null)
     {
            foreach (var item in Model.Items)
           {
               var hasChildren = item.Children != null && item.Children.Items.Any();
       if (hasChildren)
       {
                 <li>
                    foreach(var subitem in item)
       {
                      //again repeating above logic
       }
                </li>
       }
       else
       {
                //render logic
       }
          }
      }
</ul>
 </div>

but here we are limiting the multi-level menu, like as much as sub-items level that much time we are going to add foreach() logic. And If In future clients going to add one more sub navigation item with new level then it may impact to the application.

To outcome with this problem,

found magical component: @helper

@helper is:
  • resuable component
  • include code and markup both
  • easier to read
  • can call recursivly once write logic, even in the markup file.
  • can declare and define both in the view, to reduce complexity of the code.

Below is the code sample to write dynamic multi-level menu logic:

<div>
     <ul>
       @if (Model?.Items != null)
{
               @NavItems(Model.Items);
}
     </ul>
</div>

@helper NavItems(List<item> Items)
{
foreach (var item in Items)
 {
   var hasChildren = item.Children != null && item.Children.Items.Any();
   if (hasChildren)
   {
      <li>
         @NavItems(item);
      </li>
   }
   else
  {
      //render logic
   }
}
}

Above code are only for reference, please let me know if any query.


Have a Good Day.

Tuesday, 19 December 2017

~/App_Config/include has no config with fresh instance: sitecore 9

sitecore-config-info



It's strange but noticed that now with sitecore 9, there is no configs at path ~\App_Config\Include\
As per my understanding, now there is a config at path ~\App_config\Layer.config
which has following statements like:

  <layer name="Modules" includeFolder="/App_Config/Modules/" />
  <layer name="Custom" includeFolder="/App_Config/Include/" />
  <layer name="Environment" includeFolder="/App_Config/Environment/" />

that mean from sitecore 9, layer structure introduced for modules, custom, environment and others.
Since currently after fresh instance with sitecore 9 there is no custom configs that's why
~\App_Config\Include\ has no configs, and if we wanted to add some of the custom configs then will come under the custom Layer.


Saturday, 9 December 2017

Windows could not start the solr service on Local Computer: Sitecore 9 Installation

While Creating solr service with nssm-2.24.zip then service is created by but while trying to restart/start getting error as

Windows could not start the solr service on Local Computer. The service did not return an error. This could be an internal Windows error or an internal service error. If the problem persists, contact your system administrator.

I also faced same issue and to fix this here we have two approaches:
First one is - Please make sure command prompt is closed (where earlier you may ran solr start ), if not closed then first close the command prompt and then again restart solr service. It will work.

Second approach will have below steps:

1. from the cmd (as admin) at the path ~/nssm-2.24/win64 run the command as
> nssm remove solr

Now check from services that solr service is removed or not, if not
 then firstly stop solr service from service setting manually and then run the above command hope   will work.

2. after this, remove the existing nssm-2.24(from directory) and download this version of NSSM and extract at the same place.

3. now again create the solr service via this nssm version Issue will be resolved.

Let me know if any issue.

Have a Good Day!!!

Friday, 8 December 2017

Sitecore 9 Installation Scaffolding things

sitecore9-scaffolding

Sitecore 9 is the biggest announcement from sitecore.
And while doing the installation process on your system, it is necessary that all the prequiestics are there as well as at their right place. And here scaffolding will make more sense. Below is my observations and scaffolding things for Sitecore Instance.

Sitecore Instance Directory 
will contains:
 SIF(If doing installation things with the help of SIFLess.exe) / final script for Sitecore Installation
solrssl.ps1 (to generate ssl for solr).

Sitecore Repository Directory

Configs
extracted files of the configs file(XP0 Configuration files rev.171002.zip)
   License
License.xml
Solr
extracted file of the solr (solr-6.6.x.zip)
NSSM
extracted files of the nssm (nssm 2.24.zip)

Sitecore 9.0.0 rev. 171002 (OnPrem)_xp0xconnect.scwdp.zip

Sitecore 9.0.0 rev. 171002 (OnPrem)_single.scwdp.zip

SitecoreInstallFramework 1.0 rev. 171003.zip

With this way suppose in future we need more instances then we required to create only Another Sitecore Instance Directory and add SIF, Else everything it will take from Sitecore Repository.


Let me know your valuable feedbacks.

Have a Good Day!!!

Wednesday, 29 November 2017

How to Request: Free Licence to Getting Started with Sitecore

sitecore-free-licence



Hi all,

I was surfing on Sitecore official site as usual, and believe me get one offer. So I wanted to share with all that:

If any developer wanted to start with Sitecore and they don't have licence, then they don't have to worry more.

Now Sitecore started giving free Sitecore licence for developer, if raise access for free licence.

Below is the Request_to_Raise_For_Sitecore_Free_Licence

With the help of Sitecore free licence can practice with:


  • Habitat Project on Helix design Principle which is open source project, here is the Habitat_Github_Repo

So start developing with Sitecore and Welcome to New Era.

Friday, 24 November 2017

Sitecore Licence Details Option and Login Screen Image

sitecore-login-screen

Actually I was just looking login page's code and found that we can also check Licence details from Login Screen without logging.


From sitecore.config we just need to make the value="true" for setting name="Login.DisableLicenseInfo" i.e.

<setting name="Login.DisableLicenseInfo" value="true">

and below is the screen after making the changes.

sitecore-login-licence-details-options

Here may be noticed that login screen background image has been changed.

Yes also did this one, there is a change from sitecore.config as

<setting name="Login.BackgroundImageUrl" value="/sitecore/login/drop_wallpaper.jpg">


Changed with

<setting name=Login.BackgroundImageUrl" value="/sitecore/shell/themes/Backgrounds/Building.jpg">

Have a Good Day!!!

limit search result from Sitecore Content Tree

sitecore-search

Obviously it's not big issue, but sometime clients asking to limit search result while searching any Sitecore item from Content Tree.

we just need to change limit from setting to display search result.
So let's start

It's same as previously we did for limiting number of items for multi list field. from sitecore.config we need to change the value for setting for Search.ContentTreeSearch.MaxResults.

By default 25 results are listed when we search any items from content tree, and we can decrease the results list and also can increase.

<setting name="Search.ContentTreeSearch.MaxResults" value="25">

And if wanted to list all the searched result then set value as 0 (But suppose a scenario, if we have 1000+ items for searched item then it may take time or may impact to performance).

Let's take an example:

Please have a look


Sitecore config changes:

sitecore-config

Sitecore Content Tree:

sitecore-search-result


Have a Good Day!!!



Thursday, 23 November 2017

Limit number of Items for multilist with sitecore

sitecore-config

Today got an scenario, where someone wants to limit the number of items for multi list field.

Really I had no idea that time so started r&d, and yes found that there is a setting into the sitecore.config. And the big thanks to Sitecore that already handled all the things only we need to give limitation.

By default there are total 100 number of items are allowed to multi list field.

<setting name="Query.MaxItems" value="100">

and if wanted to list all of the items into the multi list field then we can set value as 0 (i.e. value="0"), but it will impact to the performance.



Have a great day!!!

Friday, 17 November 2017

3A Approach with Sitecore Componentization

Before starting development with Sitecore, if we have any prior idea about the components then it will save our times while development and as well as will be full proof.
As per my previous projects experience, always followed the componentization trick and result was great .
Generally in normal project we have around 10+ components.
And believe me once our componentization documentation is ready you feel like everything is done just need to do implementation thing. Because after this we are able to identify which components is getting repeated on which page and after that will have to apply only that rendering on particular pages.
So let's start focusing on creating Componentization Document then next jump to development.
For this Always following the 3A Approach:
1. Authorization
2. Accessibility
3. Action
This 3A magical things helped me a lot. Here I am taking an example of e-commerce site (AMAZON) for reference, please go with attached image first after parallely visit on https://www.amazon.in/ (for reference) can easily see that on the attached image things are in form of component like:
sitecore-components

On Home Page we have:
Header
Logo
Navigation
Search

Body
Carousel
Image Slider
Image Title Description Widget
Image Title Widget
Title Description Widget
Back To Top Widget
Image Links Widget
Teaser(Offer) Widget

Footer
Footer Links
Copyright

here on the homepage components are getting reused just by changing their data source. And if we jump to another page will see their header and Footer components are same just their body part will be little bit changed with some of the new/reused components.

For Proper Documentation, I shared sample Componentization Documentation, Please have a look.

Any feedback/Suggestions/Advice are welcome!!!

Tuesday, 7 November 2017

Handling 404 Error Page with Sitecore

Wanna create your own PageNotFound with Sitecore?

Suppose a scenario, where an end user is hitting wrong item and he is getting some technical error (which can not be generally understandable by End User), and you wanted to show him your own page.

Then I would like to say it's cool and quick change with Sitecore, we just need to make an entry into Sitecore Config(<instance name>\Website\App_Config\Sitecore.config) and have to create your own aspx file that's it.


Let's start a quick demo step by step:

1.  First created PageNotFound.aspx file and put it at location [<Instance Name>\Website\PageNotFound.aspx]


2. Second after this made entries to Sitecore.Config [<instance name>\Website\App_Config\Sitecore.config]


404-errorhandling-config

That's It....

custom-404-page-sitecore


@Note: Actually here we are redirecting PageNotFound: 404 Error type with Permanent Redirect: 302 by creating our own user friendly Page.

Please let me know if any feedback or suggestions.

Saturday, 14 October 2017

Creating Custom ribbon with Sitecore

Create Custom Ribbon button with Sitecore:


Before start to explain let me tell you that it's very easy to create custom ribbon with sitecore.


So let's start,


First to create custom Ribbon we will goto CORE database.
Sitecore Login Page=> Desktop=> Right bottom Select CORE database



sitecore-desktop-database

To create custom Ribbon,
We need to create first ribbon then Strip and at-last chunks.
Now the Question is what are these ribbon,strip and chunks?
So let me give this answer in One line.
As you can see from the snapshot, "Top Section is Ribbon and the area it covers as subpart are strip and the buttons are chunks."
Now to create custom we will start recursively means first will create Chunks then strips and in last will ribbon.
So all the chunks, strips and ribbons are under ribbon Tree at "/sitecore/content/Applications/Content Editor/Ribbons"

sitecore-content-tree
at this path "/sitecore/content/Applications/Content Editor/Ribbons"
under the chunks,
create custom Chunks of type "/sitecore/templates/System/Ribbon/Chunk"
and made the entry for Header and ID Field for newly created chunk.


sitecore-chunk-item






and now create custom button inside this of type "/sitecore/templates/System/Ribbon/{select your button type template}"
made the field entry for button

sitecore-ribbon
at this path "/sitecore/content/Applications/Content Editor/Ribbons" under the strip, create custom strip of type "/sitecore/templates/System/Ribbon/Strip"


sitecore strip


after creating strip to display created chunk buttons we generally divided them into separate sub parts, so to achieve this goal
we will create custom subpart under strip of type "/sitecore/templates/System/Reference"
and made the entry for reference will point to custom created chunks



at this path "/sitecore/content/Applications/Content Editor/Ribbons" under the ribbons/Default, create custom ribbon of type "/sitecore/templates/System/Reference"
and made the entry for reference field which will be pointing to chunks


That's It.

Now goto to master Database and check the Custom Ribbon.

sitecore-custom-ribbon

Hope it will help!!!

Monday, 25 September 2017

Reason behind recycling IIS while development

Recycle is one of the tasks of IIS (Internet Information Services). So before going to explain let me tell you about IIS first.


sitecore-iis-error



On the IIS we do generally:

IISRESET, to start/stop www publishing services. When we do IISREST request then it applies to all applications on that are hosted on the IIS.

RESTART, to start/stop the process for particular application. Continues the services for other hosted application without any interruption.Generally, it initializes the website.

REFRESH, we generally do this process with session-oriented applications.

RECYCLE, our main focus on this because it's faster the others like RESET or RESTART. Recycle introduced from IIS6. It designed to restart only one application Pool means worker Processes

Actually When we do recycle then it creates the new process and after that HTTP.SYS dispatch the incoming request to newly created process and once all the requested got dispatched older process destroyed automatically.

Advantages of using Recycling:

  • no lost of the current application.
  • Once the process is created then older one is getting destroyed.
  • takes the guarantee of no lost of content.
  •  faster than IISRESET/RESTART.
  • Each time new data is getting stored into the worker Processes.

We can recycle the App Pool with two ways:
1. cmd> 'run AppPool/?'
2. with IIS Manager

Now come to the IIS Manager, basically, it has mainly three main components:
1. HTTP.SYS: It's kernel component, not part of w3wp.exe. It never uses virtual memory. And the main task of this component is to route the incoming request to corresponding AppPool.

2.  Worker Processes/AppPool/ w3wp.exe: It handles all the contents and also runs the dynamic contents. such as ASP.NET App.

3. IISAdmin: it manages IIS config as window services management.



Sunday, 17 September 2017

Create custom ContentEditor Field in Sitecore?

First of all, I would like to explain about Content Editor fields in Sitecore.

So let's start, while creating a template in Sitecore we require giving field type like:
SingleLine Text
Rich Text
DateTime
Droplist
Multiline Text
etc.

Now sometimes content editor ask developers for custom Content Editor Fields in Sitecore.
So with this blog, I will create custom content Editor Field by making a replica of existing field types.

 So First go to the place where all the existing content editor fields are placed in Sitecore that mean Core Database.
sitecore-field-type-tree



Now Create your own custom field Directory at /sitecore/system/Field types where will put our customfield datatype item.





After creating custom field directory now it's time to create customField Datatype item at /sitecore/system/Field types/CustomField



sitecore-custom-field-tree




and given the assembly and class name of custom FieldDatatype as above.

Here is the code snapshot where we inherited the existing Sitecore field type item

sitecore-custom-field-class



Now come back to Master Database and on template uses this custom field datatype.


sitecore custom field type


And yes we successfully created a replica of the existing field type.

sitecore-custom-field




Now it's on you which type of custom field we wanted to implement.




Tuesday, 12 September 2017

How to Create RSS Feed in Sitecore?

Before going to start creation process,

We will go with traditional way (Safe and Solid) means first What, Why and How ?




1. What is RSS Feed?

is Rich Site Summary responsible for the delivery of continuously changing web content. For Example: Suppose you have so many sites, portals and social media platform where you want to update your latest content automatically listed then RSS come into the existence.

So it's really amazing technique for Content Publisher.

2. Why to use RSS Feed?

Why, good question.
Suppose you have content related to:

Latest Events
Latest News
Latest Blogs
Latest Offer Posts
etc..

which you want to publish automatically on the other sites, platform then use RSS Feed.

3. How to create RSS Feed for our Sitecore Instance?

Now come to last but not least, So let's start creating RSS feed in Sitecore.

Oh I forgot one important thing, Let me explain here - "to publish latest content automatically using RSS on other sites you need RSS external URL"

for example: YahooNews (http://news.yahoo.com/rss/)

Now In sitecore at which path you wanted to put your RSS item means
here I will put my RSS item at home level So that every item will be listed.




now here at this path will create RSS item of template type "/sitecore/templates/System/Feeds/RSS Feed"




after creating RSS item give the input for fields

like the link of the item to list all the descendants, Link of the instance




now design RSS for the item which we want to list to the RSS genreated link's content.


sitecore-rss-page-item

sitecore-rss-feed-design


after this, publish RSS item and also item for whom we design RSS(here will publish home item bcz we set RSS design for this item).
and hit /run on the live mode and yes we achieve this.



sitecore-rss-item


Have a Great Day, Let me know if any issue will my pleasure!!!