Skip to Content
Orchard CMS: Up and Running
book

Orchard CMS: Up and Running

by John Zablocki
May 2012
Beginner to intermediate content levelBeginner to intermediate
132 pages
3h 16m
English
O'Reilly Media, Inc.
Content preview from Orchard CMS: Up and Running

Chapter 6. Creating Widgets

In Chapter 5, we walked through the process of creating a content field. In order to be used, our field had to be added to a content type. We couldn’t just add it to a zone in a template and have it appear. For that behavior, we’ll need a widget. Like fields, widgets are a type of Orchard module. In this chapter, we’ll walk through the process of creating a widget that we can attach to all or some pages in our site.

Content Parts

Content parts are reusable pieces of functionality (UI or behavior) that are added to content types. When we created the Event content type, we added the Containable content part to its definition, which allowed events to be contained in projection pages. The Body content part allowed us to include an HTML body in our Bio content type.

Even though a widget is a content type and not a part, creating a widget is effectively the same process as creating a content part. However, we’ll include some additional metadata to make the part behave like a widget and not a part. In other words, once a part becomes a widget we can add it as content in a zone.

In this chapter, we’re going to create a module for embedding videos on our site. At the time of this writing, there exists only a single YouTube module in the Orchard Gallery. That module is a field, which again requires a content type to be defined with that field in order for it to be used with content items. What we want instead is a widget that we can attach to different pages, regardless ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

ASP.NET MVC 4 in Action

ASP.NET MVC 4 in Action

Matthew Hinze, Jeremy Skinner, Jeffrey Palermo, James Bogard, Eric Hexter
ASP.NET Core and Vue.js

ASP.NET Core and Vue.js

Devlin Basilan Duldulao

Publisher Resources

ISBN: 9781449339746Catalog PageErrata