Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Build a global configuration system via config entities.
Comment | File | Size | Author |
---|---|---|---|
#70 | 2563639-70-metatag-add-global-defaults.patch | 69.42 KB | juampynr |
#62 | 2563639-62-metatag-add-global-defaults.patch | 61.23 KB | juampynr |
Comments
Comment #2
jaxxed CreditAttribution: jaxxed at Wunder commentedThis isn't clear enough?
I am not sure why you want config entities? should this not be a single config-form (with a single config yml) or should it relate to multiple yml files? (lookup drupal console : $/> console generate:form:config)
So it seems to me that you're looking for:
1. enabling|disabling of group|tag plugins globally?
2. default global tags to use when we aren't looking at an entity page?
Notes:
1. the metatag module should be written to use a service to set|retrieve active tags, instead of a drupal_static() (then it could be used by anybody anywhere to set tags in new scenarios, and then it could automatically load defaults)
2. are we happy with the approach of checkout the CurrentRoute, matching to an entity canonical path, loading THE entity, and checking for fields? Does it make sense to use the field-formatter to ->set() values? (yes I know that teaser and list views would confuse things)
Comment #3
jaxxed CreditAttribution: jaxxed at Wunder commentedD8 is released. and all|most of the other D8 tasks are out of the way.
Comment #4
DamienMcKenna.
Comment #5
juampynr CreditAttribution: juampynr as a volunteer and at Lullabot commentedI have implemented a UI like the Drupal 7's one that manages global, entity and bundle defaults at https://github.com/Lullabot/metatag/issues/15.
Tomorrow I will start working on a patch to integrate that system with what we have at Drupal.org.
Comment #6
juampynr CreditAttribution: juampynr at Lullabot commentedHere is the first version of the patch.
Tests pass and the module works, but there is a collision: Field meta tags can have default values for each content type:
The above logic collides with the admin interface, which lets you to do the same in the same style as the Drupal 7 version does:
Shall we keep field defaults or shall we do it exactly as the Drupal 7 version does it? Personally, I prefer the latter, but I surely miss a lot of background maintaining this module.
Damien, Dave, what do you think?
In the meantime, I will create another patch for the second option (do it as in Drupal 7).
Comment #12
juampynr CreditAttribution: juampynr at Lullabot commentedHere is what I am going to work for the next patch: https://github.com/Lullabot/metatag/issues/15#issuecomment-159991027
Comment #13
DamienMcKennaPersonally I prefer to keep entity things with their entity, rather than in a separate system.
Comment #14
juampynr CreditAttribution: juampynr at Lullabot commentedThen this would be the site builder experience:
1. Install the module.
2. Open to admin/structure/metatag_defaults.
3. Adjust global and entity defaults.
4. Open http://d8.local/admin/structure/types.
5. Add the metatag field for a content type. Then set defaults. Repeat for other content types.
6. Open admin/structure/taxonomy.
7. Add the metatag field for a vocabulary. Then set defaults. Repeat for other content types.
8. When creating content, adjust metatags if needed.
I think that steps 4 to 7 will be confusing and hard to discover for site builders. This is the reason why I see value in keeping bundle defaults in the admin interface. What do you think, Damien?
Comment #15
juampynr CreditAttribution: juampynr at Lullabot commentedHere is a new patch that fixes those warnings related with
Token::replace()
.Comment #17
juampynr CreditAttribution: juampynr at Lullabot commentedI think that the failures for PHP 5.5 & PostgreSQL 9.1 3 are not related with the patch.
Comment #18
juampynr CreditAttribution: juampynr at Lullabot commentedThis patch removes the Delete operation in global and entity defaults.
Details at https://github.com/Lullabot/metatag/pull/19
Comment #19
juampynr CreditAttribution: juampynr at Lullabot commentedTests pass!
https://imgflip.com/gif/7uno1
Comment #20
juampynr CreditAttribution: juampynr at Lullabot commentedThis patch adds the ability to delete bundle defaults and to revert global and entity defaults.
Details at https://github.com/Lullabot/metatag/pull/19 and https://github.com/Lullabot/metatag/pull/20.
Comment #21
juampynr CreditAttribution: juampynr at Lullabot commentedHere is another patch that fully integrates with field defaults. Details at https://github.com/Lullabot/metatag/issues/15.
Comment #22
juampynr CreditAttribution: juampynr at Lullabot commentedThis patch adds some adjustments to the README.txt and refactors the logic to render a token browser, as not it is used by the global UI and the default field UI.
Comment #25
juampynr CreditAttribution: juampynr at Lullabot commentedWeird, I don't know the meaning of the above test failures.
Comment #26
juampynr CreditAttribution: juampynr at Lullabot commentedComment #34
juampynr CreditAttribution: juampynr at Lullabot commentedI will wait. This happened before with a previous patch and got solved magically afterwards. Seems unrelated with the patch code.
Comment #35
juampynr CreditAttribution: juampynr at Lullabot commentedComment #43
juampynr CreditAttribution: juampynr at Lullabot commentedThis patch adds metatag defaults for the front, 403 and 404 pages. Plus testing coverage for them.
Comment #44
juampynr CreditAttribution: juampynr at Lullabot commentedThis patch removes a few tag schemas which are redundant as they use the same structure as
metatag.metatag_tag.*
.Comment #45
DamienMcKennaComment #46
DamienMcKennaComment #47
DamienMcKennaHere's what I'm thinking:
Comment #48
DamienMcKennaIt also needs an update script so that any sites which had beta2 running will be able to get the functionality working.
Comment #49
juampynr CreditAttribution: juampynr at Lullabot commentedI would rather indicate at the global UI that if you want to override these defaults for a content type, then you should add the field. That would optimize the use of the global defaults. What do you think?
That is how it works. See metatag_get_default_tags().
The default fields are populated with global defaults. See MetatagFirehose::form(). Is this what you mean?
All right! I will install beta 2 and test whether we need to do something for the upgrade.
Comment #50
Dave ReidI think the current (D7) method is a big UX win for our end users. As a developer, being able to add new config instances that didn't have any relation to entity types or bundles, and had a clear path for inheritance was a huge win as well. I was also with a couple lines of code able to make default metatags for sub-pages of nodes. The current behavior in the D8 port would make those customization much harder. Having the config system for storing all the defaults and visible in one place keeps everything consistent rather than shoe-horning our data and UX into a system that doesn't, in my mind, feel prepared or appropriate for it. And does not stick to the vision originally laid out by the original module.
Comment #51
DamienMcKenna@juampy: I see your point of pushing the notion of using the defaults (something that I'm finding people still don't understand with the D7 version), so the install functionality I mentioned could instead just be a message giving a quick explanation of the intended behavior. Maybe the "overview" page I was thinking of could be used to help push this idea, and provide shortcuts to adding appropriate fields to entity bundles as needed.
@Dave Reid: I wasn't intending to *not* have a global defaults system, I just have not had any time to work on it and juampy's the first person who has (thank you thank you thank you lullabot and acquia!). By the sounds of it, there's *nothing* in juampy's patch (or my original goals for the D8 version) preventing someone from continuing to follow the D7 methodology, besides maybe some UX around the field defaults, and we're only at beta2 so we can work on improvements.
Comment #52
juampynr CreditAttribution: juampynr at Lullabot commentedSounds good.
I don't know how we could do it. At the very least, we could say at the top of the UI: "If you want to add bundle overrides, add the field Metatag and set defaults".
I removed bundle defaults from the admin UI because it would be confusing as they would collide with field ones. However, if we are up for fully removing field defaults, then I could get them back. See this pull request for an screenshot: https://github.com/Lullabot/metatag/pull/14.
Comment #53
DamienMcKennaKinda going back to what I mentioned earlier - what if the UX presented as a field's default settings is just a copy of the appropriate global defaults, i.e. store the "field defaults" in the global configuration? Then it'd be two different ways of accessing the same thing, but they'd just be stored in one place - the global configuration. I had been thinking of doing something like this on the D7 branch anyway - make the global settings also available on the respective bundle form to make it easier to find all of the settings.
Comment #54
juampynr CreditAttribution: juampynr at Lullabot commentedSounds good to me!
How about when we edit a node? Should we also show the metatag fiedls and store overrides in config?
Comment #55
DamienMcKennaNo, entity values must be stored in fields, otherwise we're damning ourselves to have to duplicate code to properly handle revisions and translations, as happened with the D7 branch.
Comment #56
juampynr CreditAttribution: juampynr at Lullabot commentedHere is an updated version of the patch that takes into account #2613654: Parse image fields for image URLs.
Comment #58
juampynr CreditAttribution: juampynr at Lullabot commentedFor the moment and for simplicity, I will just hide the ability to edit or delete the Metatag field. Bundle defaults would be editable only at the admin UI.
Based on the latest comments, I am working in the following tasks:
Does the above list look okay to both of you?
Comment #59
DamienMcKennaAlso: any update scripts necessary to make it work correctly when updating from beta2.
Is hook_uninstall() supposed to remove fields now? I thought the Field API system was supposed to block uninstalling modules if any of its fields are still in use?
Comment #60
juampynr CreditAttribution: juampynr at Lullabot commentedIf we install fields automatically and don't let users set default in them, then we should remove the fields ourselves as well when the module is uninstalled. This may be impossible if Drupal checks for field dependencies before calling hook_uninstall(). Does this make sense to you Damien?
Comment #61
juampynr CreditAttribution: juampynr at Lullabot commentedGiven that Drupal does not allow you to delete metatag fields on hook_uninstall() as the ModuleInstaller field validator blocks it, we should not add the fields to all the bundles on hook_install() because that would make uninstalling Metatag painful (you would have to manually remove all fields before uninstalling).
Based on the above, I will abort the task list from #58 and simply add messages on install and at the top of the administration interface as we discussed at #52.
Here is my new TODO list:
Does the above look okay?
Comment #62
juampynr CreditAttribution: juampynr at Lullabot commentedThis patch implements everything listed at #61 except from the hint on wheter a node's metatag is using defaults or being overridden. I don't think that this is a show stopper though and I feel that this is the best we can do to integrate Config API with Field API.
Please check out the patch and test it. I will set up beta 2 and work on a database update.
Comment #68
DamienMcKennaTest-failures aside, this sounds awesome, juampy! Thank you (and Lullabot, and Acquia)!
And remember, we can continue improving the UX once the architecture is in place.
I'll try to review it this weekend.
Comment #69
DamienMcKennaSo there'll need to be two update scripts:
Comment #70
juampynr CreditAttribution: juampynr at Lullabot commentedThis patch adds a database update for beta2. I tested it by installing beta2, adding a few fields with default values, and then replacing the code by this patch and running the database update.
I could not figure out how to remove the field defaults of the existing fields after creating config entities, but I am not too worried about it.
Damien, is there anything else that I should implement for this patch?
Comment #72
juampynr CreditAttribution: juampynr at Lullabot commentedThose PostgreSQL failures have happened before sporadically. I would ignore them.
Comment #73
DamienMcKennaThanks, I'll test it later today and let you know.
Comment #75
DamienMcKennaThis is just awesome! I've reviewed it and it works rather nicely as a first pass, we can do follow-up improvements in other tickets.
Thanks juampy, Dave Reid, Lullabot and Acquia!
Comment #76
juampynr CreditAttribution: juampynr at Lullabot commentedNice @Damien! For follow ups, could you list here what the priorities would be? Then I could help with them but at a slower pace.
Comment #77
DamienMcKennaThe i18n support would be an important one. Otherwise, I'm sure we (the Drupal community) will find things to improve.