Monday, May 16, 2016

What is difference between droplink and droplist in Sitecore?


Today one of my friend asked me what is the basic difference between Droplink vs Droplist in very simple words. I replied that...

Droplink:
Droplink  stores the GUID(Unique in space and time) of the item that was chosen by content editor.

Droplist:
Droplist data type only stores the string value of the item that was chosen by the content editor.

Saturday, March 19, 2016

How to invoke/Call custom Pipeline


To call the pipeline use the CorePipeline.Run method as follows:
var pipelineArgs = new MyPipelineArgs();
 pipelineArgs.DbName = master;
 pipelineArgs.Item = blogCommentItem;

 CorePipeline.Run("CustomPipeline", pipelineArgs);




Simple way to create Branch Template in Sitecore

Please follow the below steps to create branch template in Sitecore.

Step 1:
Create a folder "Region" and withing Region folder Create a simple template name "Country" with two fields "Title" and "Description".


Step 2:
Duplicate the Item and name it to "City" and "State".
Step 3:
Within "Branch" create new folder named "Region". Right click --> Insert-->New Branch -->popup will open--> choose "county" template.

Please follow the below screenshot....










Simple way to Sort Sitecore Items in the Content Editor


Right click on the item you want to sort, Just shown in below screenshot


Now you can sort Subitem like creation date,Display Name,Reverse order etc.

Creating sitecore item programmatically based on template


Creating sitecore item programmatically based on template:



    public void CreateItemBasedonTemplate()
        {
           
            using (new SecurityDisabler())
            {
                //First get the parent item from the master database
                Database masterDb = Sitecore.Configuration.Factory.GetDatabase("master");
                Item parentItem = masterDb.Items["/sitecore/content/home/MyItem"];
               
                //we need to get the template from which the item is created
                TemplateItem template = masterDb.GetTemplate("sample/sample item/My Template");
               
                //Now we can add the new item as a child to the parent
                parentItem.Add("NewItem", template);

             
            }
        }

Friday, March 4, 2016

How To Publish Item CM To CD with c# code

Very simple way to Publish any Item CM To CD using c# code
public static bool PublishItemCMTOCD(Database DbName, String ItemId)
        {
            Item item = DbName.GetItem(Sitecore.Data.ID.Parse(ItemId));
            bool flag = false;

            if (item != null)
            {
                Sitecore.Publishing.PublishOptions publishOptions =
                  new Sitecore.Publishing.PublishOptions(item.Database,
                                                         Database.GetDatabase("web"),
                                                         Sitecore.Publishing.PublishMode.SingleItem,
                                                         item.Language,
                                                         System.DateTime.Now);  
                Sitecore.Publishing.Publisher publisher = new Sitecore.Publishing.Publisher(publishOptions);

                // Choose where to publish from
                publisher.Options.RootItem = item;

                // Publish children as well?
                publisher.Options.Deep = true;

                // Do the publish!
                publisher.Publish();
                flag = true;
            }           

            return flag;
        }

Saturday, February 27, 2016

Step to install Mongodb

Step to install Mongodb:
1.  Install the mongo db by clicking on “mongodb-win32-x86_64-2008plus-2.6.3-signed.exe”
2. create “MongoDB” folder in D:\ drive.
3. Create two folders named Data and Log within MongoDB folder.
4. Create Mongo.log file in Log Folder.
5. Create “mongodbconfig.cfg” file in D:\ MongoDB floder.
6. run the below command
C:\Program Files\MongoDB\bin\mongod.exe --config "D:\MongoDB\Mongodbconfig.cfg" –install
7. go to services.msc and start the mongodb service.

That’s it. Mongo db is installed and started.

Validation:


INSTALL MONGODB Resources: