Custom Fields

custom-logo2.pngUsually blogs have well known structure, which is understandable; one of the core ideas behind blogs is ability to "talk" to each other using RSS, format that defines very strict set of entries like "post", "category" or "tag". Also common format helps to move data from one blog engine to the other making your data portable - big plus. But there are times when you want to go beyond this limitation, and add something valuable to you and your readers. So there is need to extend blog's data structure somehow to hold this extra data. For example WordPress adds meta tables for most main entities, and you have post meta, comment meta, user meta etc. I don't necessarily like this approach as it tightly binds extensibility points to existing structure. To borrow from famous Rumsfeld's rant, those are "known unknowns", and sometimes we have to deal with "unknown unknowns". Maybe single generic entry where post or user defines a type would be a better choice, because then we could add new type instead of creating new entry (table). This also allows (oh my!) to have meta for meta entries and not just stick another key/value pair into the post or comment.

Lets examine common scenario to make it less confusing. Say I'm theme author, I added social icons to the theme and share it with others. First thing everyone would want to do is replace my info with their own. It makes sense to have account and maybe icon picture customizable, so people don't have to manually modify HTML in the theme template. Same goes for things like logo, cover image etc. - little modification here and there always required. That is a snap for developers but major annoyance for average blogger. There is a need for little customizable snippets in the theme that can be modified through UI instead of raw HTML. For the theme, we could have something like this in the template:


Application would parse HTML before sending it to the browser and replace tokens with values (two icons on the right).


Theme template has default values specified, but they can be changed via admin UI. Most intuitive way probably using edit entry screens, which all standard in new BlogEngine. Here you could manage custom fields for specific type, like theme, post or category. Not only themes can benefit from this, we could also add similar records to hold information specific to the post, category, entire application - anything.


When you can add and edit these custom fields, they can be used and manipulated in application in many creative ways. For a theme, it would mostly be token replacement with saved values. But you could also create extension to password protect blog post where blogger can add custom field to the post for a password. Or extend category to have an image. And you not restricted to admin UI to change values, custom fields exposed over Web API and for authorized user there can be completely custom UI loaded outside admin. Take a look at this slide-in panel, it is used to customize theme's appearance and behavior. This all can be loaded and saved from and to custom fields with Ajax calls.


These only few examples, custom fields can be very powerful and provide framework for a deep customization and extensibility only limited by creativity and imagination. First implementation in coming BE 2.9 will be simple, but overtime it can grow into very nice and useful feature.


This site is all about developing web applications with focus on designing and building open source blogging solutions. Technologies include ASP.NET Core, C#, Angular, JavaScript and more.