Sunday, 20 August 2017

Implement Sitecore Solr Simple Search in 5 mins

Follow the below steps to search by item name

  1.  you just need to add references of the Solr content Seach from visual studio
  2.  Add the below code in your class file as a method

     List<SearchResultItem> results;

            using (var context = ContentSearchManager.GetIndex(indexName).CreateSearchContext())
            {
                var predicate = PredicateBuilder.True<SearchResultItem>();
    
                // must have this (.and) if you want o query specific path then enable below line
                //predicate = predicate.And(p => p.Paths.Contains(FolderItem.ID));
    
                // must have this (.and)
                predicate = predicate.And(p => p.Name == searchTerm);
    
                results = context.GetQueryable<SearchResultItem>().Where(predicate).ToList();
            }
  3.  Finally, Rebuild indexes from Sitecore control panel

Friday, 28 April 2017

Online Pdf language translator


Below link is useful for translation of pdf file across all languages. If we need English then add en in the url, for german add de like that.

https://www.onlinedoctranslator.com/en/translationform

Thursday, 4 August 2016

How to get rendering view or action name in razor view

To get controller name:

ViewContext.RouteData.GetRequiredString("controller")

To get action name:

ViewContext.RouteData.GetRequiredString("action")

Friday, 1 January 2016

How to return Javascript from an ASP.NET MVC controller action

We can use ContentResult to return the content from the MVC controller action method

Public ActionResult Helloworld()
{
    return Content("<script language='javascript' type='text/javascript'>alert('Hello world!');
}

Extracting Nupkg files using command line

Rename it to zip first then extract files as below 1.     Rename-Item -Path A_Package.nupkg -NewName A_Package.zip 2.     Make sure to repla...