Hi. I have my own entity which has no use for metatag module but metatag auto-injects itself into it's edit form. How to disable metatag for my entity? In metatag_entity_load there should be some setting for this. I don' want to create hook_entity_load just to unset metatag.
| Comment | File | Size | Author |
|---|---|---|---|
| #18 | metatag_optional.zip | 6.18 KB | JvE |
| #12 | metatag-n1429100-12.patch | 2.64 KB | damienmckenna |
Comments
Comment #1
charlie-s commentedDitto to this request. It's very cool that it auto-attaches itself to entities, but there are many entities that are not used in a standalone page format (field_collections being one, although they certainly can be displayed as a standalone page).
Comment #2
charlie-s commentedI don't know all of the procedures for doing this the right way. I imagined that the UI for this could provide an 'edit' button for the field settings on any fieldable entity's "manage fields" form, e.g. admin/structure/field-collections/field-name/fields, and that the 'edit' page would provide a checkbox to disable metatags for the field_collection (among other possible settings). But this approach kind of then requires that metatag's field settings would apply globally for an entity and not per bundle, right? Then that would be a bit funny since it doesn't appear to be working with bundles ATM.
If anyone reads this and knows where to start with changing the field options I'd love to hear it, I've been wanting to get a richer understanding of how fields infos are setup.
Anyways, in the mean time, here's what I'm doing to hide metatags from my field_collections:
Comment #3
Anonymous (not verified) commentedI'd also like to see this feature added to a settings page where you can select which entity types metatag should attach itself to. On our current project we have several extra entity types, but none of them needs metatags added, only nodes do. Disabling metatag frees up about 5MB of memory per pageload, which really is a lot and not acceptable.
Comment #4
kevinquillen commentedI tried this in a form alter:
My form fields updated to hidden, yet were still visible on the form. I also tried unset(), which took them out of the form array, but it still displayed on the add/edit form of custom entities where I do not need it. How can you effectively hide or get rid of this for forms?
Comment #5
longwaveIn hook_entity_info() you can set 'metatags' => FALSE, or similarly via hook_entity_info_alter():
Comment #6
Anonymous (not verified) commentedIt works. Thanks. Maybe update a documentation or project page regarding this.
Comment #7
socialnicheguru commented#5 worked for me
Comment #8
kenorb commentedI've custom form done in ctools (when calling ctools_wizard_multistep_form) and Metatag thing appears without reason and by default, so I don't see any reason that it should be there.
Following function:
add metatag stuff to any possible form, which is very bad approach.
It cause serious problems with the theming.
I've tried #5, but it doesn't work.
In my opinion this needs to be fixed.
Workflow is as follow:
Related issue:
#1371968: Show/Hide Meta tags fieldset per content type
Workaround:
Comment #9
miaoulafrite commentedfor field collection it would be:
Comment #10
murzThis way is only hides metatags from entity edit form, but not disable loading and other operations with metatags. So better is to create option in metatag module for disable metatags in custom entity.
Comment #11
murz#5 solves the problem thanks.
But can I disable metatag by default for all entities and enable only for selected?
And will be good to see this feature configurable in metatag settings page, instead of php in custom module.
Comment #12
damienmckennaA question for @davereid: should the module instead explicitly define (via hook_entity_info_alter()) which of the entity types support meta tag and not automatically assume everything does? Try this patch for size.
On an aside, I need to delve further into it to see if this really stops the API from trying to load.
Comment #13
damienmckennaComment #15
longwaveAgreeing with Damien here, many entities, custom or otherwise, do not need or use metatags, so providing them should be opt-in not opt-out.
Comment #16
kenorb commentedYes, I agree, by default it shouldn't break the things (theme, etc.) after just enabling it.
See as well: #1644554: Wizard shows other module fieldsets on every step #4
Comment #17
Bensbury commentedI used the Module Hook solution to disable Meta Tags on field collections, but I also would like to decide which content types / entities use meta-tags.
For quite a lot of things I use it is unnecessary and I only hope to use meta-tags on my parent Node/Object.
eg. Node-blocks, content types which only appear as teasers or as a slideshow don't need them, comments, field collects and so on.
I think this is important because there doesn't appear to be any alternative to Meta Tags for D7.
Please share if I am wrong.
Comment #18
JvE commentedI've attached a quick little module I whipped up for this.
Install it and navigate to admin/config/search/metatags/optional to decide for yourself which things you want to disable metatags on.
Comment #19
damienmckennaTag.
Comment #20
damienmckennaRelated: #1281770: Disable metatags by default on all entitity types, enable it only on needed and popular types - nodes, terms
Comment #21
dave reidThis will be solved with #1281770: Disable metatags by default on all entitity types, enable it only on needed and popular types - nodes, terms rather than forcing it to be defined in hook_entity_info(). Easier solution is to check if the entity type or bundle actually has configuration or not. This makes them opt-in rather than opt-out.
Comment #21.0
dave reidadded info