WordPress.com



Sitecore Command TemplateWe can create a command template that displays no user interface, a command template that uses a JavaScript prompt to collect an item name, or a command template that displays an or Sitecore Sheer user interface.We can assign command templates along with data templates and branch templates?using insert options.Following example demonstrates creation of a command template which would check if a folder with current year name exists under main item “News”? and add a “News Item” in that folder. This example uses a JavaScript prompt to collect News Item name.Step 1:?Create two templates with required fields as per the requirement.NewsNews Items. Step 2:?Create a class NewsItemCommand that inherits from?Sitecore.Shell.mand,?and override the?Execute()?method.Step 3:?Add a /configuration/command element to the file /App_Config/Commands.config. <command name="newscategory:newsitem" type="basesite_sitecore_mvc.Areas.ABCD.Models.NewsItemCommand, basesite_sitecore_mvc"/>Step 4:?Under the appropriate project-specific folder within?/sitecore/Templates,?insert a command template definition item using?/System/Branches/Command Template?data template.Step 5:?In the command template definition item, in the Data section, for the Command field, enter the command code.The parameter id=$ParentID passes the ID of the item under which the user is inserting a new item. Without this parameter, Sitecore would pass the ID of the selected item rather than the item the user right-clicked.newscategory:newsitem(id=$ParentID)Step 6:?Assign this command template to standard values of the “News” template created in step1.Step 7:?Create a new aspx page in “/sitecore modules/shell” Step 8:?Complete required code in the command class.Step 9:?Handle “OK” and “Cancel” buttons of the user “Command Template.aspx”Step 10:?Create a main news item based on “News” template.Step 11:?Create a news item under main item by clicking the command template which would create a folder with current year and a “News Item” under that folder.New folder will be generated according to the current year and item will be placed under it. ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download