21 votes

What is the best way to bulk-create items programmatically?

I have outlined 3 options for you below. Rocks is perhaps the easiest to setup and use but isn't so easy to use on remote environments. SPE is perhaps the most flexible and powerful option. Writing ...
user avatar
17 votes

What is the best way to bulk-create items programmatically?

Sitecore PowerShell Extensions provides a great way to create items in bulk. Here is a simple script. foreach($index in 1..10) { $item = New-Item -Path "master:\content\home\sample item$($index)"...
user avatar
  • 16.5k
17 votes
Accepted

What does headless mean in the context of Sitecore?

What is a Headless CMS? A headless CMS is a back-end only content management system (usually built from the ground up as a content repository) that makes content accessible via an API for display on ...
user avatar
13 votes
Accepted

How can I write my own custom disabler?

Sitecore's built in disablers, like the SecurityDisabler and the EventsDisabler classes, all inherit the Sitecore-provided Switcher class. This class is an IDisposable that can be used to create ...
user avatar
13 votes
Accepted

Is there a method in Sitecore's utilities to format a numerical file size in a friendly way?

You are correct, you probably have come across this. The Sitecore.StringUtil, Sitecore.Kernel class contains a number of methods for managing strings. The two methods in particular are: StringUtil....
user avatar
  • 14.4k
13 votes
Accepted

Exposing ServiceApiController in Sitecore 9.2

You have most of the pieces you need, but not all. You need a patch config <configuration xmlns:patch="http://www.sitecore.net/xmlconfig/"> <sitecore> <initialize> ...
user avatar
  • 24.4k
12 votes

How to get the our local date and time from the sitecore datetime field(raw value format - yyymmddThhmmssZ)?

Sitecore stores its date/time values in UTC. And you are 5h30m ahead or behind UTC. If you'd like to display DateTimes in Server Time: webDB = Sitecore.Data.Database.GetDatabase("web"); var item = ...
user avatar
  • 24.4k
12 votes
Accepted

Headless CMS : Sitecore vs Contentful

Full disclosure: I'm on the JSS team, so naturally I'm biased. Contentful is fairly similar to using Sitecore's SSC REST APIs. You have a large bucket of content, and you have an API to retrieve ...
user avatar
  • 4,083
12 votes
Accepted

When to use Sitecore.Context.Items and why?

Sitecore.Context.Items is a collection that exists for the lifetime of the http request. I use that collection for times when I need to store some data as part of a request where I will need that ...
user avatar
  • 18.9k
11 votes
Accepted

TemplateManager.GetTemplates always returning null

Yea. Change your code to this: var templatePath = "User Defined/Project/Common/Content Types/Links"; var template = TemplateManager.GetTemplate(templatePath, Context.Database); If your path starts ...
user avatar
  • 24.4k
11 votes

What is alternative of ".PageMode.IsExperienceEditor" property in JSS-react?

In addition to the built-in helper method, the pageState (normal, preview, editing) and pageEditing (boolean) properties are also available in the layout service context, which there are samples of in ...
user avatar
  • 4,083
10 votes

Service based architecture in sitecore

Yes, it is possible to achieve your architecture using Sitecore. There are a few options for you here to do headless implementations, each with their own advantages and disadvantages, and different ...
user avatar
  • 6,491
10 votes
Accepted

How to rebuild Lucene Index using API?

You should have a look at the documentation form Sitecore: https://doc.sitecore.net/sitecore_experience_platform/80/setting_up_and_maintaining/search_and_indexing/indexing/rebuild_search_indexes You ...
user avatar
10 votes
Accepted

Accessing SXA Site Grouping Site Settings Properties from Code

These items can be queried using code like this: var siteInfo = ServiceLocator.ServiceProvider.GetService<ISiteInfoResolver>().GetSiteInfo(Context.Item); if (siteInfo != null) { var ...
user avatar
  • 16.5k
9 votes
Accepted

How do I get an Item from Sitecore's internal URI protocol?

It's Sitecore.Data.ItemUri format. You can use var itemUri = ItemUri.Parse(string itemUriString) to get ItemUri class object and then Sitecore.Data.Database.GetItem(ItemUri itemUri) to get the ...
user avatar
9 votes
Accepted

"Silently" Create Item - Create Item Without Triggering Indexing or other Events

If you decompile and have a look at the Sitecore.Data.Items.ItemEditing class, in Sitecore.Kernel, you will find that all the EndEdit(bool) method does (and the relevant parts of its overload methods ...
user avatar
9 votes

What is the best way to bulk-create items programmatically?

Sitecore actually provides an OOTB item generator tool, named "FillDB." You can access this tool by navigating to http://yoursite.com/sitecore/admin/filldb.aspx. Before you can use the tool, you will ...
user avatar
9 votes
Accepted

What is alternative of ".PageMode.IsExperienceEditor" property in JSS-react?

That would be isExperienceEditorActive defined in @sitecore-jss/sitecore-jss. Usage: import { isExperienceEditorActive } from "@sitecore-jss/sitecore-jss"; if (isExperienceEditorActive()) { // Do ...
user avatar
9 votes

What’s the best practice to Expose Sitecore 9 APIs for Mobile Apps Development?

Sitecore JSS is pretty match to your requirements in terms you want to use analytics, tracking, rule engine personalization, control on component rendering. But you should't think about JSS in ...
user avatar
9 votes
Accepted

JWT tokens for authentication for 9.0 UPDATE 1

You can implement custom DelegatingHandler base on Sitecore.Services behavior: using System.Linq; using System.Net.Http; using System.Security.Claims; using System.Threading; using System.Threading....
user avatar
  • 3,011
9 votes
Accepted

The type or namespace name 'Job' could not be found (are you missing a using directive or an assembly reference?)

The Sitecore.Jobs.Job and Sitecore.Jobs.JobOptions classes have been removed in Sitecore 9.2. In their place you now have BaseJob and BaseJobOptions abstractions with DefaultJob and DefaultJobOptions ...
user avatar
  • 17.8k
8 votes

Best way to Use Sitecore Data for other Application?

This is a tricky question to answer as what is "best" can often depend on your solution. So let's look at the options: Item Web API - as @sitecorebasics said, the Item Web API is not supported in ...
user avatar
  • 18.9k
8 votes
Accepted

Item statistic "CreatedBy" returning empty string

"Statistics.CreatedBy" property does not return standard values. To fix this problem please use : blogPost.Fields["__created by"].Value Statistics.Created use next code: private string ...
user avatar
  • 17.8k
8 votes
Accepted

How to copy an item to multiple locations

SPE is likely going to be your best lower effort approach. The book provides several examples for creating Context Menu options and prompting for input. Creating New-Item allows for the creation of ...
user avatar
  • 16.5k
8 votes
Accepted

Change field type from Droplist to Droplink

You cannot use the existing data directly to go from drop list to droplink as they stored data differently. Droplist has the display name, and droplink has the GUID of the item. In order to convert, ...
user avatar
  • 6,491
8 votes
Accepted

How to unlock sitecore items programmatically

There is a Locking API that you can use. Now it is up to you how you will process all items and unlock them. You can create a job, SPE (Sitecore Powershell Extensions) script.
user avatar
8 votes
Accepted

What is Sitecore.Abstractions dll?

Quoting Ruud van Falier (Sitecore.Abstractions.dll in Sitecore 7.5): Sitecore 7.5 ships with a new binary named Sitecore.Abstractions.dll This offers you abstractions for some parts of the ...
user avatar
7 votes
Accepted

Field StandardValue vs DefaultValue vs FallbackValue vs InheritValue vs InnerValue

Inner value: the "raw" value (as you can see in the editor) Standard value: value inherited from Standard Values of the template Fallback value: value inherited through field fallback Inherit value: ...
user avatar
  • 19.2k
7 votes

Sitecore search for multiple children with same name and path

Your problem is that the links will be generating a path, and all the links will have a path like: /newsitems/news Sitecore can only match an item there by path name, so its going to pick the first ...
user avatar
  • 18.9k
7 votes
Accepted

How to invoke Workflow on the particular item using Sitecore API?

Here is code which changes workflow state and executes actions: public static WorkflowResult ChangeStateAndExecuteActions(Item item, ID workflowStateId) { using (new EditContext(item)) { ...
user avatar

Only top scored, non community-wiki answers of a minimum length are eligible