Monday, March 18, 2019

SIF LESS Sitecore Installation




PREREQUISITES

ü Sitecore Installation Framework
ü Solr 6.6.2
ü SQL 2016
ü Powershell 5
ü WebDeploy 3.6
ü NET Framework 4.6.2 or later 
ü Windows OS (8.1/10 or Windows Server 2012 R2 (64 bit) or higher) 
ü Sitecore Package
ü Xconnect Package

Step 1 :

  Download the SIF package

Step 2 (Optional) :

Ø Extract the SIFLess file
Ø Store all required file in one common folder









Step 3 :

Ø    Extract the SIFLess File .
Ø    Run the SIFLess execution file from SIFLess folder
Ø    The popup will appear like this
Ø    Fill all the information
   

Step 4 :

Fill all the information
Click the test

Got an error


  
Go to Services, Run the Solr (got an error while restarting this).

Solution

Ø Go to control panel -> System ->advance setting -> Environment variable
Ø Check Java version(need to check the installed java version)
Ø Go to cmd -> java -version
Ø Change it to the environment variable.
Reason For Issue:
   Java version is upadated automatically in my system,thats why I am changing my environment variable.
   
  Step 5 :

Uncheck the generate files only


Step 6:

Click generate files and install


Ø It takes few minutes to install…




Uninstall Using SIF Less

  After installation your SIF Less Folder having two folders looks like this:



Step 1:

Download the uninstall script from

Step 2:
    Download script file


  Copy all this files to SIFLess Folder
Step 3:

Ø Open PowerShell
Ø Set your Directory location
Example: Set-Location -Path D:\SiteCore\SC9.0\SIFLess
Ø Run Uninstall Script
Ø PS =>D:\SiteCore\SC9.0\SIFLess> .\SIFless-EZUninstall-1538220607


Got an error while uninstalling



Solution :

ü    Just open Uninstall script
ü    Verify PSScriptRoot path is correct
      Example:
$PSScriptRoot = "D:\SiteCore\SC9.0\SIFLess"
    
Happy Coding !!!

Quotes Of The Day
    
   I'm not a great programmer; I'm just a good programmer with great habits.

Sunday, March 17, 2019

Custom Sitecore Helpers


Why?

      Sometimes you need more functionalities and you wish you could extend the Sitecore HTML helper. I will show you two possibilities for how you can easily accomplish this.

Uses:

      It's very simple and your co-developers don't even need to know if this method is a Sitecore extension or your custom code, they can simply use it the same way as it would be a Sitecore helper method.

Extension methods:

The Asp.net HtmlHelper, as well as the SitecoreHelper class, are normal classes, that means you can write extension methods for it.So
If you want to extends the Sitecore HTML helper with a custom implementation, you just need to write an extension method for the SitecoreHelper class:

public static class SitecoreFieldHelper

    {
        public  static HtmlString CustomImageField(this SitecoreHelper helper, string fieldname,
             int mh, int mw, bool disablewebEditing = false)
        {

            return helper.Field(fieldname, new { mh, mw, DisablewebEditing = disablewebEditing });

        }
    }

Which you can call with:
   
 @Html.Sitecore().CustomImageField("Profile Theme", 200, 300, true)

Custom HtmlHelper

Extension methods have one big disadvantage: You can't override methods nor can you use protected methods of the "original" HTML helper. So another possibility is to write a custom HTML helper the same way as Sitecore does. The goal is to have something we can call like this:

  @Html.CustomMethod().MethodToCall()

Step 1:

       Here the concept is very easy. CustomMethod() is an extension method of the ASP.NET HtmlHelper and returns a new instance of our custom HTML helper, which inherits from the SitecoreHelper. First, we need the custom HTML helper with a new method:
    
  public class CustomHtmlHelper : SitecoreHelper
    {
        public CustomHtmlHelper(System.Web.Mvc.HtmlHelper htmlHelper)
        : base(htmlHelper)
        {
        }
        public virtual HtmlString CreateLabel(string key, string DefaultValue)
        {
            return new HtmlString(string.Format("<label'>{0}</label>", key));
        }

}

Step 2:

Last but not least we need to write the HtmlHelper extension method to get your custom helper:

   public static class HtmlHelperExtensions
    {
        public static CustomHtmlHelper CustomMethod(this HtmlHelper htmlhelper)
        {
            // get the helper from current thread
            var threadData = ThreadHelper.GetThreadData<CustomHtmlHelper>();
            if (threadData != null) return threadData;

            // create new helper if needed
            var helper = new CustomHtmlHelper(htmlhelper);
            ThreadHelper.SetThreadData(helper);
            return helper;
        }
}

Step 3:

       Now we are able to use it:

     @Html.CustomMethod().CreateLabel("Lable Static Text Here", "Label Name")

In theory, you are now able to "forget" the Sitecore HTML helper and always use your custom one. This would have a similar effect to your co-workers like extension methods. Because we inherit from the Sitecore HTML helper, you can also call its method over the custom class:

   @Html.CustomMethod().Field("My Field")

Happy coding !!!

Quotes Of the Day !!!

  Programs must be written for people to read, and only incidentally for machines to execute.


Steps to follow when using a PowerShell script to modify the goals in Sitecore

I have previously utilized PowerShell for item creation, modification, deletion, and presentation details in Sitecore.   Ø Recently, I attem...