Showing posts with label Standard Template. Show all posts
Showing posts with label Standard Template. Show all posts

Wednesday, 31 July 2019

How to Create Custom Standard Values Tokens



Out of the box, Sitecore comes with the following expand standard values tokens:

$name – Name of the item
$date – Current server date
$time – Current server time
$now – Current server date time
$id – Item ID
$parentid – Item’s Parent ID
$parentname – Item’s Parent Name

Sometimes the already existing tokens are not enough. There are cases in which the Content Editors won`t be able to access the value that needs to be populated (ex. – web service call) or it will be hard for them to do it (ex. – the value of the item varies on many other items). In the current example, the $next token will be implemented. It will automatically replace the token with the current siblings' count plus one  – this token is usually used in cases where there is a requirement for the auto-incrementing sort order of items.

Implementing a custom token is fairly simple and can be achieved in 2 easy steps.

Step 1 – Creating a custom ExpandInitialFieldValueProcessor

Create a custom ExpandInitialFieldValueProcessor with the following code.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Sitecore.Pipelines.ExpandInitialFieldValue;

namespace SitecoreMaster82.Models.CustomToken
{
    public class TokenNextProcessor : ExpandInitialFieldValueProcessor
    {
        public override void Process(ExpandInitialFieldValueArgs args)
        {
            if (args.SourceField.Value.Contains("$next"))
            {
                if (args.TargetItem != null && args.TargetItem.Parent != null && args.TargetItem.Children != null)
                {
                    args.Result = args.Result.Replace("$next", args.TargetItem.Parent.Children.Count.ToString());
                }
                else
                {
                    args.Result = args.Result.Replace("$next", "0");
                }
            }
        }
    }
}

The code is pretty straightforward. It checks if the value of the field contains the $next token. If it does it checks if the parent is not null and the parent has children. If the parent is not null and there are children the value is set to the children`s count (the processor is executed after the child is added to the index will be 1 based), otherwise it sets the value to 0.

Step 2 – Creating the custom configuration

<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <pipelines>
      <expandInitialFieldValue>
        <processor type="SitecoreMaster82.Models.CustomToken.TokenNextProcessor , SitecoreMaster82"
       patch:after="processor[@type='type=Sitecore.Pipelines.ExpandInitialFieldValue.ReplaceVariables, Sitecore.Kernel']" />
      </expandInitialFieldValue>
    </pipelines>
  </sitecore>
</configuration>

And here is an example of how it works.









Friday, 14 June 2019

Sitecore Standard Template Fields - Part-7



Sitecore Standard Template: Validators Section

The Validators section of the Sitecore standard template contains the following fields used to configure data validation for the item:
  • Quick Action Bar Validation Rules (N/A): Item validators to apply in the Quick Action Bar.
  • Validate Button Validation Rules (N/A): Item validators to apply in dialogue that appears when a CMS user clicks the Validation button in the Proofing group on the Review tab of the ribbon in the Content Editor.
  • Validator Bar Validation Rules (N/A): Item validators to apply in the Validation Bar.
  • Workflow Validation Rules (N/A): Item validators for the validation workflow action to apply.
  • Suppressed Validation Rules (N/A): Item validators suppressed for this item.

Sitecore Standard Template: Workflow Section

The Workflow section of the Sitecore standard template contains the following fields that control workflow for the item:
  • Workflow (Sitecore.FieldIDs.Workflow): The workflow currently associated with the item.
  • Workflow state (Sitecore.FieldIDs.WorkflowState): The workflow state currently associated with the item.
  • Lock (Sitecore.FieldIDs.Lock): Identifies the owner of the lock associated with the item, preventing other non-admin users from editing that item.
  • Default workflow (Sitecore.FieldIDs.DefaultWorkflow): The workflow into which the system should place versions of the item when CMS users edit it. In general, unlike other fields in the Workflow section, the __Default workflow field should have a value in standard values for the data template associated with the item.

Thursday, 13 June 2019

Sitecore Standard Template Fields - Part-6



Sitecore Standard Template: Statistics Section

The Statistics section of the standard template contains the following fields (that have nothing to do with web statistics, personalization, testing, or any other aspect of experience management):
  • Created (Sitecore.FieldIDs.Created): The date and time at which the system created the version. I believe that tracking the actual item created date rather than the version created date may require customization (maybe there is a technique in the box, but it currently escapes me, as the creation date of the first version could vary by language).
  • Created by (Sitecore.FieldIDs.CreatedBy): Identifies the CMS user that created the version. I believe that tracking the actual item creator rather than the version creator may require customization  (maybe there is a technique in the box, but it currently escapes me, as the of the first version could vary by language). 
  • Revision (Sitecore.FieldIDs.Revision): A unique identifier that the system updates (almost) every time the item changes. I write "almost" because passing certain parameters to specific APIs prevents Sitecore from updating this field.
  • Updated (Sitecore.FieldIDs.Updated): The date and time at which the system last updated the version. Again, passing certain parameters to specific APIs prevents Sitecore from updating this field.
  • Updated by (Sitecore.FieldIDs.UpdatedBy): Identifies the CMS user that last updated the version.

Sitecore Standard Template: Tagging Section

The Tagging section of the Sitecore standard template contains a single field:
  • Semantics (Sitecore.Buckets.Util.Constants.SemanticsField): Stores tags that CMS users and potentially visitors to the live site can use to search for items.

Sitecore Standard Template: Tasks Section

The Tasks section of the Sitecore standard template contains the following fields:
  • Archive date (Sitecore.FieldIDs.ArchiveDate): Date/time after which the system can archive the entire item.
  • Archive Version date (Sitecore.FieldIDs.ArchiveVersionDate): Date after which the system can archive the version of the item.
  • Reminder date (Sitecore.FieldIDs.ReminderDate): Date after which to send a reminder notification by email.
  • Reminder recipients (Sitecore.FieldIDs.ReminderRecipients): Email addresses of recipients for the reminder email.
  • Reminder text (Sitecore.FieldIDs.ReminderText): Text to send in the reminder email.


Wednesday, 12 June 2019

Sitecore Standard Template Fields - Part-5



Sitecore Standard Template: Publishing Section


The Publishing section of the standard template contains fields for managing publishing restrictions at the item level. Sitecore manages version-level publishing restrictions in fields within the Lifetime section of the standard template.

  • Publish (Sitecore.FieldIDs.PublishDate): Date after which publishing operations can publish the item to publishing targets.
  • Unpublish (Sitecore.FieldIDs.UnpublishDate): Date after which publishing operations will remove the item from publishing targets.
  • Publishing groups (Sitecore.FieldIDs.PublishingTargets): Publishing targets associated with the item. Publishing Groups is a legacy term for functionality similar to publishing targets.
  • Never publish (Sitecore.FieldIDs.NeverPublish): Prevents publishing operations from publishing the item to publishing targets.


Sitecore Standard Template: Security Section

The Security section of the Sitecore standard template contains the following fields:
  • Owner (Sitecore.FieldIDs.Owner): Identifies the CMS user that owns the item. From what I can tell, the owner is typically the user who created the item or its latest version in a language, although it is possible to change ownership of an item explicitly through the UI (or by changing the value in this field). Note that the owner does not necessarily own the current lock (the __Lock field in the Workflow section specifies the current lock owner if any).
  • Security (Sitecore.FieldIDs.Security): Defines access rights for the item. One key thing to remember here is that when you change access rights for an item, you must publish those changes to any relevant publishing target database(s).

Monday, 10 June 2019

Sitecore Standard Template Fields - Part-3



Sitecore Standard Template: Insert Options Section

The Insert Options section of the standard template contains fields that define insert options for the item. Insert options control which types of items CMS users can create (insert) beneath existing items. In general, best practice is to assign insert options in standard values for data templates rather than individual items.
  • Insert Rules (N/A): Insert rules to apply to insert options. In general, I advise the use of insert options rules, which use the rules engine, rather than insert rules, which use functionality more specific to insert options.
  • Masters (Sitecore.FieldIDs.Branches and Sitecore.FieldIDs.Masters): Insert options for the item (masters is an old name for functionality similar to insert options).

Sitecore Standard Template: Item Buckets Section

The Item Buckets section of the standard template contains fields that affect buckets and bucketing. Buckets support storage, path management, search, an nd other features for very large numbers of Sitecore items. Most of these fields apply to buckets, of which most solutions should have very few if any. The __Bucketable and __Should Not Organize In Bucket fields are exceptions to the previous statement, as they apply to items within buckets. In general, those fields should be set in the standard values of the templates associated with those items rather than in individual items.
  • Bucket Parent Reference (Sitecore.Buckets.Util.Constants.BucketParentReference): Set to the ID of the parent of the item before its relocation into a bucket. Unbucketing an item moves it back under that parent. Sitecore stores a value in this field automatically as appropriate.
  • Is Bucket (Sitecore.Buckets.Util.Constants.IsBucket): Indicates that an item is a bucket.
  • Bucketable (Sitecore.Buckets.Util.Constants.BucketableField): Indicates that an item should be hidden if it exists in a bucket. It
  • Should Not Organize In Bucket (Sitecore.Buckets.Util.Constants.ShouldNotOrganizeInBucket): Indicates not to apply bucketing operations to the descendants of an item (it will maintain its structure within a bucket).
  • Default Bucket Query (Sitecore.Buckets.Util.Constants.DefaultBucketQuery): Default filtering for bucket Search pane.
  • Persistent Bucket Filter (Sitecore.Buckets.Util.Constants.DefaultFilter): Similar to __Default Bucket Query, but read-only (CMS users cannot change the search criteria for the bucket).
  • Enabled Views (Sitecore.Buckets.Util.Constants.EnabledView): Views enabled for this item. In this context, views expose alternate user interfaces for working with items in a bucket.
  • Default View (Sitecore.Buckets.Util.Constants.ItemViews): Default view for working with items in a bucket.
  • Quick Actions (Sitecore.Buckets.Util.Constants.QuickActionField): Quick actions expose CMS operations in views and potentially other user interfaces.

Sunday, 9 June 2019

Sitecore Standard Template Fields - Part-2


Sitecore Standard Template: Help Section

The fields in the Help section of the standard template can provide context-sensitive assistance to users working with items in Sitecore. The fact that properties that expose the IDs of these fields appear in the Sitecore.TemplateFieldIDs class may indicate that Sitecore intends these fields to be relevant only to data templates (or at least, populated in data template definition items rather than standard values or individual items).
  • __Help link (Sitecore.TemplateFieldIDs.HelpLink): I could not easily find any usage of this field. I can imagine using it to develop a system that provides links to further information for working with items, for example in the Quick Info section to generate a link to external documentation, or to make the short description a link to such documentation. In that case, I feel that the field should appear in the data template for data templates rather than the standard template.
  • __Long description (Sitecore.TemplateFieldIDs.Description): Appears when a user hovers over an item in the content tree (what one might refer to as a tooltip…)
  • __Short description (Sitecore.TemplateFieldIDs.ToolTip): Appears in the item title bar.

Sitecore Standard Template: Indexing Section

The Indexing section of the standard template contains the following fields:
  • Boost (Sitecore.ContentSearch.Utilities.BoostingFieldId): Affects the relevance of item when it appears in search results.
  • Boosting Rules (Sitecore.ContentSearch.Utilities.BoostingRulesFieldId): Sitecore invokes the rules selected in this field to adjust the relevance of the item when it appears in search results.
  • Facets (Sitecore.Buckets.Utils.Constants.FacetsField): Item-specific search facets added to the global facets defined under the /Sitecore/system/Settings/Buckets/Facets item



Sitecore Standard Template Fields - Part-1



Sitecore Standard Template: Advanced Section

The Advanced section of the standard template defines the following fields:
  • Source (Sitecore.FieldIDs.Source): For clone items, identifies the cloned item.
  • Standard values (Sitecore.FieldIDs.StandardValues): For template definition items, the ID of the item that defines standard values for the template. It seems that logically, this field belongs in the data template for data templates rather than in the standard template for all items.
  • Tracking (Sitecore.Analytics.AnalyticsIds.TrackingField): For managing analytics properties associated with the item, including Profiles, Goals, and other Attributes (Campaigns, Events, Failure Actions, and Settings, including disabling analytics features for an item).

Sitecore Standard Template: Appearance Section

The Appearance section of the standard template defines the following fields:
  • Context Menu (Sitecore.FieldIDs.ContextMenu): Custom context menu for the item (often set in standard values for the template associated with the item).
  • Display name (Sitecore.FieldIDs.DisplayName): Display name for the item.
  • Editor (N/A): I believe that this field may be obsolete, or at least deprecated, from a time when items supported only a single custom editor.
  • Editors (Sitecore.Buckets.Utils.Constants.Editors): Custom editors (tabs) associated with the item (often set in standard values for the template associated with the item).
  • Hidden (Sitecore.FieldIDs.Hidden): To hide an item in content trees, select this checkbox for that item.
  • Icon (Sitecore.FieldIDs.Icon): Icon to render for the item (often set in standard values for the template associated with the item).
  • Read Only (Sitecore.FieldIDs.ReadOnly): To protect an item from updates, select this checkbox for that item.
  • Ribbon (Sitecore.FieldIDs.Ribbon): Configures a custom ribbon for the item (often set in standard values for the template associated with the item).
  • Skin (Sitecore.FieldIDs.Skin): For theming items in the Content Editor. To my knowledge, I have never seen this used.
  • __Sortorder (Sitecore.FieldIDs.Sortorder): For sorting items in content trees.
  • Style (Sitecore.FieldIDs.Style): For applying styles to items in content trees and fields in the content editor.
  • Subitems Sorting (Sitecore.FieldIDs.SubitemsSorting): For managing rules for sorting child items in content trees.
  • Thumbnail (Sitecore.FieldIDs.Thumbnail): Thumbnail image used for example when selecting a rendering.
  • Originator (Sitecore.FieldIDs.Originator): According to Sitecore’s own glossary, the intention of this appears to be the storage of the ID of the item in a branch template used to create an item. This did not seem to be the case in my simple tests, although there do seem to be some items in the Core database that have a value in this field that seems to match this purpose. The code that I think would populate this field appears obfuscated, so I gave up researching.
  • Preview (Sitecore.FieldIDs.Preview): Manages screenshots of the rendered item from various browsers.


Friday, 7 June 2019

Sitecore Standard Template Fields - Part-4



Sitecore Standard Template: Layout Section

The Layout section of the standard template contains the following fields that control how Sitecore renders an item:
  • Renderings (Sitecore.FieldIDs.LayoutField): Often defined in standard values for data templates, this is the field in which Sitecore stores shared (unversioned/untranslated) layout details for items.
  • Final Renderings (Sitecore.FieldIDs.FinalLayoutField): Typically defined in individual items rather than standard values, this is the field in which Sitecore stores the versioned and translated components of layout details.
  • Renderers (Sitecore.FieldIDs.Renderers): This is the field in which an item can specify renderers (for rendering items in the context of a page generated from another item) for use by the Sitecore.Web.UI.WebControls.ItemRenderer web control or the ItemRenderer MVC renderer.
  • Controller (Sitecore.Mvc. Names.FieldNames.Controller, which actually provides the name of the field rather than its ID): This field can specify an MVC controller to invoke when a client requests the item.
  • Controller Action (Sitecore.Mvc. Names.FieldNames.ControllerAction, which also provides the name of the field rather than its ID): This field can specify the name of an action method in the MVC controller to invoke when a client requests the item. A value in this field makes sense only when the __Controller field has a value.
  • Presets (Sitecore.Web.WebEditUtil.LayoutPresetsFieldId): This field can store references to preconfigured layout details that users can apply to items.
  • Page Level Test Set Definition (Sitecore.Analytics.AnalyticsIds.PageLevelTestDefinitionField): Manages page-level tests for the item.


Sitecore Standard Template: Lifetime Section


The Lifetime section of the standard template contains fields for managing publishing restrictions at the version level. Sitecore manages item-level publishing restrictions in fields within the Publishing section of the standard template.


  • Valid to (Sitecore.FieldIDs.ValidTo): The date after which publishing operations will remove the version from publishing target databases.
  • Hide version (Sitecore.FieldIDs.HideVersion): Prevents publishing of the version to publishing target databases.
  • Valid from (Sitecore.FieldIDs.ValidFrom): Date after which publishing operations will remove the version from publishing target databases.


Sitecore Publishing Service 7.0 Installation Guide

  About the Publishing Service module The Publishing Service module is an optional replacement for the existing Sitecore publishing methods....