I'm not sure if there is a better way but I choose to extend the metatag module - https://www.drupal.org/sandbox/kalpaitch/2781475 - to allow plugin derivatives for tags such that they could be created from some other source, primarily to enable new tags to be added from config or other non-code sources.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

kalpaitch created an issue. See original summary.

DamienMcKenna’s picture

That would be really awesome!

kalpaitch’s picture

However, when doing this I discovered that in MetatagManager class the form method assumes that the array keys returned by the sortedTags method are plugin IDs, this is actually not the case when using derivatives as in my example module above. I don't know whether this is intentional or if there is some other way, but I wanted to submit this patch to allow plugin derivatives for metatag tags.

kalpaitch’s picture

Category: Feature request » Bug report

Actually given this stops derivers from being used I'm going to label this as something other than a feature request...

DamienMcKenna’s picture

Component: Code » User interface
Category: Bug report » Feature request

No, this is a feature request, the module was not designed with this functionality in mind.

kalpaitch’s picture

Could I raise this as an important patch because the use of 'id' as the plugin name is not 100% accurate, the 'name' property represents the plugin name. Thanks.

kalpaitch’s picture

Status: Active » Needs review
kalpaitch’s picture

Title: Allow metatag tags to be defined through config/cms » MetatagManager should use the instance name rather than plugin id to identify plugin instances

If the same plugin (id) is used for more than one instance (derivatives) then the MetatagManager will currently just hand back the last of these instances and ignore the rest.

This sort of fits in the grey area between bug and feature request, plugins definitions are originally keyed by name and not id, would be grateful if you had another look, thanks.

DamienMcKenna’s picture

Just to see, lets try changing the group handling too.

Status: Needs review » Needs work

The last submitted patch, 9: metatag-n2781485-9.patch, failed testing.

kalpaitch’s picture

Status: Needs work » Needs review
FileSize
4.44 KB
2.66 KB

Yes, the groups also needed changing. I've made a few small updates to your patch.

kalpaitch’s picture

  • Missed a couple of instances where the plugin instance name should have been used.
  • Also I reckon that '$included_groups' and '$included_tags' should be supplied with plugin instance name and should check for this, but also keeping the check for plugin id as well. For all existing cases plugin instance name and plugin id are the same, however this is mainly for derivative plugins where the id might be 'test_plugin' and the instance name might be 'test_plugin:first_one'. In this case it allows inclusion of all instances of a plugin or of specific tags. Not sure which way you'd like this to go?
DamienMcKenna’s picture

I'm honestly not sure. I might just commit path #12 as-is, but I need to think through your question.

kalpaitch’s picture

Been thinking about this a bit more and I think it works having both plugin id and instance id. Leaving as-is.

DamienMcKenna’s picture

Status: Needs review » Fixed
Parent issue: » #2563615: Plan for Metatag 8.x-1.1 release

Committed. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.