Saturday, March 19, 2016
Simple way to create Branch Template in Sitecore
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);
}
}
{
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”
1. Install the mongo db by clicking on “mongodb-win32-x86_64-
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:
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.
Subscribe to:
Posts (Atom)
















