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.
Document Metatag's APIs and provide examples for:
- Creating new meta tags.
- Disabling meta tags provided by default by the module.
- Adding meta tag support to new entities.
- Loading meta tags for a given entity.
- How to customize the form fields.
Original issue:
Any examples out there showing how to use the API to "define your own meta tags"?
Thanks!
Comment | File | Size | Author |
---|---|---|---|
#12 | metatag-n1466292-12.patch | 6.67 KB | DamienMcKenna |
#2 | metatag-n1466292.patch | 216 bytes | DamienMcKenna |
Comments
Comment #1
DamienMcKennaWe need to fully document this for the 1.0 release.
Comment #2
DamienMcKennaA placeholder so other issues have somewhere to add details to.
Comment #3
DamienMcKennaI've committed this file, but more work is needed.
Comment #4
silkogelman CreditAttribution: silkogelman commentedSweet, thanks!
I can't wait to define my own (Token based) meta tags.
Great stuff.
Comment #5
silkogelman CreditAttribution: silkogelman commentedExample on how to create your own meta tags using Metatag module.
http://www.agileapproach.com/blog-entry/creating-custom-meta-tags-metata...
Comment #6
DamienMcKenna@s1l: Excellent post! Thank you!
Comment #7
DamienMcKennaMarked #1709218: Metatag API Documentation as a duplicate.
Comment #8
DamienMcKennaMarked #1391968: Document how to disable/modify meta tags as a duplicate.
Comment #9
DamienMcKennaMarked #1308164: Documentation Please! as a duplicate.
Comment #9.0
DamienMcKennaClarified the issue.
Comment #10
DamienMcKennaMarked #1655082: How to load metatags/opengraph tags for a specific node? as a duplicate.
Comment #11
DamienMcKennaMarked #1318182: Custom tags as a duplicate.
Comment #11.0
DamienMcKennaProvided more details on what needs to be documented.
Comment #11.1
DamienMcKennaDocument how to customize form fields.
Comment #12
DamienMcKennaThis is a starting point, all new hooks are at least added to metatag.api.php and everywhere the hooks are triggered there's a comment to say what the hook name is.
Comment #13
DamienMcKennaI've committed #12 to keep the ball rolling, but it needs further work.
Comment #14
DamienMcKennaRTFM, manual, readme, help, ponies.
To help people find this page via the issue search. ;)
Comment #15
remkovdz CreditAttribution: remkovdz commentedIs it already possible to make a field (eg Description) required and if so: can anyone help me with it? I'm not a very experienced coder...
Comment #16
Dubs CreditAttribution: Dubs commentedPlease can you quickly explain how to load meta tags for an entity (including any defaults setup)?
I've tried metatag_metatags_load, but this doesn't seem to work :-(
Comment #17
DamienMcKennaComment #18
DamienMcKennaLets keep this issue focused on documenting the new hooks, leave #1858116: Document how to use Metatag's functions to manage using Metatag's funtions for other uses.
Comment #19
escoles CreditAttribution: escoles commentedRe. #5: Can someone please confirm that the proper procedure for adding a metatag, to be managed via metatags module, is to write a module?
Comment #19.0
escoles CreditAttribution: escoles commentedAdded the question of one of the issues that was marked as duplicate.
Comment #20
DamienMcKennaSome documentation was added recently, taking this off the blockers list and will work on it further post-1.0.
Comment #21
DC_Marc CreditAttribution: DC_Marc commentedCan you provide an example on how to trigger your metatag_presave hook? Saving a node with metadata doesn't seem to do it, at least based on my dsm calls. And is the documentation for this hook missing a $language parameter (based on the .module file around like 415 as of beta7) of the function?
Thanks!
Marc
Comment #23
alvar0hurtad0Here's a related issue:
#2678004: Complete api documentation
Maybe one can be marked as duplicate.
Comment #24
Devaraj johnson CreditAttribution: Devaraj johnson as a volunteer and commentedIs there any way to make the Meta description field mandatory and limit the field to number of char(160 max) and accordingly change the meta description field description.
Any help will be really useful. Also if we can document it in this page it self it will be great.
https://www.drupal.org/project/metatag/issues/1391968#comment-7291458
https://www.drupal.org/project/metatag/issues/1466292#comment-6874960
I see few folks are also trying to get the answer.
Comment #25
DamienMcKenna@Devaraj: Please see #2309017: Automatically trim meta tag lengths (D7).