jordanlev Posted September 10, 2014 Share Posted September 10, 2014 I'm attempting to write a module that will create some templates, fields, and pages upon installation. I found this helpful forum thread that shows the code: https://processwire.com/talk/topic/4921-how-to-create-template-file-using-api-under-a-module/ ... but I am curious what is the conceptual difference between fieldgroups and templates? Looking at the database of a basic install, I don't see any records in the fieldgroups table that are not also represented in the templates table. Is it possible to have fieldgroups that are not part of a template? If so, what are some use cases for this? If not, then why even have two distinct entities instead of combining them into 1? Thanks! Link to comment Share on other sites More sharing options...
Martijn Geerts Posted September 10, 2014 Share Posted September 10, 2014 Several templates can have the same fieldgroup. Say you build a site for a greengrocer, and you want to sell fruit. You want to have different templates for apples pears and oranges, but don't need different fields, then you could share 1 fieldgroup with the apples pears and oranges templates. This way you could search $pages->find('template=apples') and find only apples, but use the same logic for pears and oranges. It could save you time & extra logic. When you delete a template with the API, be sure to delete the fieldgroup to, if it is the last template that uses the fieldgroup. 3 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now