Skip to main content

Posts

Showing posts from 2017

Getting More from the RTE: Snippets and Styling

Developers often push aside the rich text editor because we would rather of use separate components with data sources. However, sometimes we need to rely on the rich text editor to empower the content editor to edit more directly or to reduce complexity on the page. We can use snippets to reduce complexity or give the editor more options by inserting some predefined HTML into the rich text editor. In this example, we will learn how to get more out of the rich text editor by changing which editor we use, adding new snippets, and styling the added content. First we need to switch from the default basic rich text editor to either one of the other existing editors or to a custom editor. The Rich Text Default view - just the basics: We can change the default editor on a field-by-field basis. Update the Source Property for the Rich Text field so that it references the specific rich text editor we want to use in the core database: On your template, enter the item path for the

Null Explosion Prevention with Datasources!

Sometimes bad data can sneak into the smallest of things and wreak havoc on a site bringing up a dreaded error page (hopefully captured and prettified). We’re going to cover two examples of sneaky bad data blowing up a component and how we can address the problem. The scenario here revolves around an invalid datasource and a component making use of Glass - this bad data can come about from a publishing issue (such as publishing the page which references a datasource that hasn’t been published or wasn’t in the final workflow step to allow publishing), or some other kind of issue (an invalid item ID, a deleted item still being referenced etc). 1. Getting the Item In the code for our rendering, we want to grab that datasource item to help out our model, so we did the following: This confirms that the Guid is a valid format - but doesn’t confirm that it’s a valid item in the database before we pass it to GetItem to grab and cast to our Item_Type. It wouldn't be unreasonable to