Hi! I have a question regarding Tailor. Before it, I would always create a model, for example: Product. I know it’s more time consuming but I find it positive to have the records in it’s own table and also being able to add custom methods to the model (in the php file). Now tailor looks amazing and really looking forward to adopt it, but I’m not sure how those aspects work. Can I add custom methods to the “model” created? How is the DB structure? I couldn’t find it in the docs, maybe I missed it
I just started with Tailor too so I can’t tell you much.
The data is stored in it’s own table(s) though. Don’t know if Tailor adds more overhead compared to when you create your own plugin.
I would like to know more about custom methods too.
When creating your own plugin I can create my own columns.yaml file. What I would like to know is how to extend columns in Tailor. For example I have an entry with a price field. This field is not shown in the column list. Don’t know how to get the field in the list.
Or when a related field is shown in a record, only the title of the related field is shown. How to extend this with other fields from the related table.
Hello and welcome!
Tailor is analogous to the RainLab.Pages plugin, except on steroids. If you have to include methods on your models, then you should probably be working with a plugin. As a general rule:
- Tailor is used for content management
- Plugins are used for business logic and functionality
The technology behind Tailor is quite powerful, models are dynamic and composable based on their field definitions in the blueprint. This is achieved using Tailor Fields, the documentation for this can be found here:
By building your own tailor fields, you can still potentially add methods, relations, validation, etc. to the
Tailor\Models\EntryRecord model. The content fields interact with the model using the
extendModelObject override method.
Whilst the line may be blurry and there is potential for Tailor to completely replace plugins, we don’t recommend this path because Tailor will always be specifically tuned for publishing content. In future plans, there will be a dedicated blueprint type used to add custom fields to any model. This should offer the best of both worlds.
I hope this helps.
Thanks @daftspunky, overlooked this in the docs.