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:

Tuesday, September 29, 2015

Field’s raw value in Sitecore

A field's raw value is something like what the data is stored in underlying database.







You will not find any difference for single line text's raw and rendered value but will find difference between link,image etc raw and rendered value. Please see the above screenshot for raw and rendered value of a image. Basically the raw value of the image is XML.