Custom Fields for Posts
See original GitHub issueWithin the top 15 requested features on the Ghost Feature Wishlist, this feature has been waiting for some love since 2015.
I volunteer to help out with this feature’s development.
Brief Overview
Ghost is one of the most customizable publishing platform for the general public out there, and sports most of the major benefits of all its competitors. However, every now and then comes a blogger with a vision for a design, and that vision requires complete customization of the fields on the core model objects. Think, featured image subtitle, featured link as replacement for image_ (video content, tweet, facebook embed, soundcloud), and even more. With the advent of apps, this feature will most likely gain further support as the custom fields will be readily accessible just like any other fields on the core model objects. It is most likely that apps will seek to alter the content and/or the structure of the database, and to allow such behaviour will result in a maintenance mess. Hence it is important to allow such customization now with proper separation of concerns so that later features can use its power at the fullest.
Feature Details
Custom Fields Themselves
- Custom Fields should be implemented as fields that are available across all objects of a model, with each instance/row having its own value for the said property.
- Each core model affected should have its own set of custom fields defined by the user, without commonality with each other.
- Custom Fields should be easily accessible from the block helpers used in the hbs templates
- Custom Fields should be easily usable by non-technical personnel so that the widest audience possible be able to use them.
Core Models Affected
Iteration 1
- Post
Iteration 2
- User (gender, sexual orientation, age, behance/deviantart/instagram/some social media, etc can be seen as potential use cases)
Other Models
I do not foresee the need for any extra custom fields on other models at the moment. If anybody has a very good use case, I’ll update this section accordingly.
Proposed UI Workflow
I am no designer, but here is what I came up with.
- Custom Fields are to be accessible from the General Settings (general.hbs) view
- Custom Fields are to be added/removed dynamically and easily. Type of the field (Number, Text, Boolean) can be specified for later retrieval and parsing by the model
- Each post has access to the Custom Field menu through its Settings menu
- Each post has its own value for the Custom Fields that can be specified in their Custom Field menu
Scope of the changes
After my preliminary analysis of the codebase yesterday, here is what I gathered:
Ghost
core/server/models/custom-field
is to be created as a table representing the custom-fields for each other linked table (see below)core/server/models/custom-field-value
is to be created as a table representing the values associated to each core model object which has the said custom fields (see below)core/server/models/post
andcore/server/models/user
are to be modified to allow read, mutation, deletion of custom fields.core/server/helpers/post_class
andcore/server/helpers/author
are to be potentially modified to include the custom field helpercore/server/helpers/custom
helper has to be created to allow users to template using thecustom
block helper and output helpercore/server/api/*
API endpoints have to be modified accordingly to support modification of the custom field and custom field value models. It is undetermined at the moment whether this should be done through theposts
andusers
endpoints or through thesettings
endpoint.
Quick DB Class Diagram
Ghost-Admin
General Settings Page
app/controllers/general
Unclear whether modifications should be done on this file. It does play a significant role however in contacting the server to update the settings under the General page (general.hbs)app/templates/settings/general.hbs
Modify the layout to include the new custom field settings. Will require the creation of a newcomponent
for the layout shown in the second mockup.app/models/setting
Include a new field to validate on the model. Will require the creation of a newember-data Transform
in order to support and validate the custom field.
Editor Page
app/mixins/editor-base-controller
May need modification to allow mutation and save of the custom fieldsapp/components/gh-posts-settings-menu
Modify to include the design seen in screens 3 and 4. May require the creation of an extra components for dynamically generating the list of custom fields on screen 4.app/models/post
Include a new field to validate on the model. Will require the creation of a newember-data Transform
in order to support and validate the custom field values.
Expected Time Investment
Activity | Estimate | Conservative Estimate |
---|---|---|
Supplementary Analysis | 3h | 6h |
Implementation (Ghost) | 10h | 20h |
Testing (Ghost) | 10h | 20h |
Implementation (Ghost Admin) | 10h | 20h |
Testing (Ghost Admin) | 4h | 8h |
TOTAL | 37h | 74h |
This is undoubtedly a large epic, and would benefit from being undertaken by multiple individuals / be broken down in smaller user stories.
Drawbacks
- Potential bottleneck on the CustomField / CustomFIeldValue table if accesses are done often. With proper caching practice should not be problematic however.
- Requires changes to large portion of the Ghost/Ghost-Admin software
- Increases maintenance debt by increasing the codebase
- Feature may not be necessary for a large portion of the target market but nevertheless eases a significant portion of the user base and facilitates future symbiosis of apps
Alternatives
- Custom install on self-hosted version
- Front-end with external database
- Apps with ability to modify existing database structure (and potentially requiring reboot for each new modification)
It is an understatement to say that this list of alternatives is unsatisfying. Friends, the future without custom fields is dire 😱
Let us not allow ourselves to follow such a dark path.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:73
- Comments:24 (5 by maintainers)
Top GitHub Comments
Lack of custom fields drove me away from ghost unfortunately. I know it’s definitely not a simple undertaking.
I can understand your point. I send you love. I suggest we wait and see what others think. On my side I am truly confident that this feature will make some people smile 😄 👽 🔮