As a continuation of #1281770: Disable metatags by default on all entitity types, enable it only on needed and popular types - nodes, terms (I hate reopening old issues), the only entities that should have Metatag enabled should be ones that are known to work, it should be otherwise disabled by default.

CommentFileSizeAuthor
#4 metatag-n1846080.patch4.99 KBdamienmckenna

Comments

damienmckenna’s picture

Tag.

caschbre’s picture

Just to provide an example where I'm running into the issue of metatags showing up on entity/bundles where they are not necessary...

I'm using fieldable_panels_panes and noticed that all of my bundles have the metatag field on the 'manage display' tab. There probably isn't a reason to have metatags there and I'm not quite sure how to remove them.

So my question is how would I remove them with code? I'm defining my bundles in code so I can easily remove the metatag the same way.

Ideally we'd provide a UI mechanism, but for now the code method would suffice.

damienmckenna’s picture

I'm going to change metatag_entity_info_alter() and metatag_entity_supports_metatags() so they will be opt-in rather than opt-out.

damienmckenna’s picture

Status: Active » Needs review
StatusFileSize
new4.99 KB

This should do it.

This patch updates metatag_entity_info_alter(), removes all logic from metatag_entity_supports_metatags() that tried to determine whether an entity was Metatag-worthy and instead will only deem the entity_type/bundle compatible if specifically assigned. I've also added example code to the API docs for how to enable Metatag support in new entities, and added a note to the README.txt file about it too.

In my testing this did not make any difference when just using Drupal core, but I did not see any ill effects with Field Collection.

caschbre’s picture

Thanks! I'll give this a try later today.

caschbre’s picture

Looks good so far. Metatags no longer appear on my fieldable_panels_panes and are still available on my nodes.

damienmckenna’s picture

Status: Needs review » Fixed

Committed.

Status: Fixed » Closed (fixed)

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

sk2013’s picture

I have a quick question... and I am really thankful for any pointers:

I do not want to show the Meta Tages fields on certain content types. ( Totally not want to show).. Will this patch help me to fix the issue currently I am having? Or is there any alternative approach to disable Meta tag fields to some content types?

Thanks for the help,
Senthil

mrpauldriver’s picture

Further to #9.

Please could someone confirm whether there is now a simple way to disable metatag per content type?

There seem to have been a number of similar issues and it has all become a bit confusing.

JvE’s picture

Since "content-type" equals "bundle" for entities of type "node" this functionality is requested in #1286270: Option to disable meta tags per entity/bundle/object.

mrpauldriver’s picture

Thank you. As well as adding to my grasp of Drupal terminology, this also gets me on the right issue for now :-)

sk2013’s picture

Hi JvE,

Can you confirm the patch that works for the scenario? I am quite confused.

Thanks

JvE’s picture

There is no working patch for this. It is not possible to disable metatags for content-types without writing your own module.
See this issue comment for an example. I don't know if that code is still valid though.

damienmckenna’s picture