Hey guys,
here we go again. So after we know all relevant items and templates we can now go to create some and demonstrate how easy it is (after you know how
).
Let’s create a chunk to demonstrate how to create your own strip:
/sitecore/content/Applications/Content Editor/Ribbons/Chunks: You find all existing chunks in Sitecore here. To create your own: Insert a new Item of the type “Chunk” (/sitecore/templates/system/ribbon/chunk). There are different fields in the data section (You have to scroll down to see them.).
- Header: self explaining, isn’t it? - It’s the text below the buttons
- Click: That is a command field, for my series I will call it that way. Commands are strings which are definied in App_Config/Commands.config. You have to specify the name and the type attribute.
Be careful: The name has to be lower case!
The type is “<namespace>.<class name>, <assembly name>”. This type is the link to the class which inherit the command class (Sitecore.Shell.Framework.Commands.Command). You have to implement the abstract method: public override void Execute(Sitecore.Shell.Framework.Commands.CommandContext context). The context parameter passes the current item in context.Items[0] (mostly, I didn’t find any methods where it is not).
If you fill a value there, you will get a clickable header on the bottom, like the insert chunk where you can set your allowed templates.
- Access key: Does not make sense for me, though. I don’t know how to move to a chunk by having an access key. Also I did not find any examples for this behaviour in Sitecore. Maybe some Sitecore devs can tell me more about it.
- Tool Tip: Same here. I can’t find where it is displayed when I filled it with some value.
- ID: Now get back to the important fields. This field has to be unique and no white spaces in it. I think you all know element ids and the requirements. I’m always using “<myChunkName>Chunk” as the value.
After you did this, you have your own chunk without any buttons. I will get back to the possible buttons and panels in my next post by demonstrating all buttons.
Let’s see how to integrate your own strip with your empty chunk. Go to Ribbons/Strips and create a new item of the type “Strip” (/sitecore/templates/system/ribbon/strip), there you have different fields:
- Header: Self explaining, the title of the strip
- Contextual Header: Sorry, but I can’t get this to work. If anyone knows how to use this field, please add a comment.
- ID: Same as above, unique id of the current element.
- Access key: Type a char in there and you can access your strip by pressing [alt] + <your Access key>
- Tooltip: A tooltip next to the header of your strip.
- Type: Of course you can create a dynamically strip which could be personalized, pulls something from an external database etc. The type is in the “normal Sitecore format”: <namespace>.<class name>, <assembly name>
Great! So far so good. After you created your strip, you need to let the strip know which chunks are in there. That’s why we created an empty chunk first. Under your strip you have to create a new item of type “Reference” (/sitecore/templates/system/reference) and give it the name of your chunk. There you will find a field called “Reference”: link your chunk here.
Now, if you want to see your strip in the Sitecore Client Content Editor, you have to go to …/Ribbons/Ribbons/Default and create a new item of type “Reference“, give it the name of your strip. Link your newly created strip item in the reference field.
After you saved the current item, you can right-click on your ribbon navigation and should now see your strip unchecked. If you click on your strip, it will get inserts in the content editor.
Other locations like WebEdit / Preview or Debug are also possible, I will tell you where in my next posts. As well as all possible buttons and panels you can add.
Have a nice sunday, I will go out for some sports now and enjoying the sun
cheers chris