Hi guys,

Thanks very much for this great module and all the efforts made on documentation.

While working with the latest versions of the metatag [7.x-1.0-beta4+19-dev (2012-12-06)], metatag_views [sandbox] modules, I was brought to look closer into the API hooks currently provided and in particular: hook_metatag_config_default.

While trying to work on #1856218: Add a default configuration for Views meta tags related with the metatag_views [sandbox] module, I got a little stuck for a while because I couldn't figure out why my implementation of hook_metatag_config_default (so metatag_views_metatag_config_default()) wouldn't get picked up by the metatag API.

I started digging a bit, which brought me to metatag.module, line 243, metatag_config_load_multiple that calls ctools_export_load_object, which then brought me further into the Chaos tool suite (ctools) module and in particular, ctools/includes/export.inc.

Anyhow, that got me an express crash course on exportables in ctools API :-)... all that to find out that I was missing an implementation of hook_ctools_plugin_api() and not any implementation: it should be exactly the same one as in the module itself
metatag.module, line 51, metatag_ctools_plugin_api

  * Implements hook_ctools_plugin_api().
function metatag_ctools_plugin_api($owner, $api) {
  if ($owner == 'metatag' && $api == 'metatag') {
    return array('version' => 1);

So for a module implementation, only the function name should be changed to: function [modulename]_ctools_plugin_api($owner, $api), the rest of the code could stay the same.

A very good example for these hooks implementations (hook_metatag_config_default along with hook_ctools_plugin_api), could also be found in the great sandbox module Views metatags (Dave Reid).

Concerning Features export, I have noticed that it's actually the hook hook_metatag_export_default that is used and didn't look much into it yet, but I already saw some Features API integration in metatag_features_api.
After testing, it seems Features doesn't need to include in its generated hook_ctools_plugin_api in its features_name.features.inc file, the declaration code for the metatag API code above, in particular if ($owner == 'metatag' && $api == 'metatag') (is not needed in features_name.features.inc).

To wrap it up, I just wanted to document a little bit of my investigations in this ticket, so it could at least save some time to others that would stumble on the same questions/problems.
Please find attached to this ticket a patch for the API, file: metatag.api.php, to document a bit hook_metatag_config_default.
[File attached as: metatag-document-hook_metatag_config_default-0.patch]
For the doc/comment part, you may recognize a format or style familiar, from other modules, the Views module, in particular, from which the major part was copied and adapted to fit with the module.
I also tried to include a quick example of implementation, as a simple template or indication for those who would like to start off with something then modify.

Could you please let me know if I overlooked or missed anything in the current metatag module (and its API), in terms of whether the documentation is correct or not?

Please let me know if you would have any questions on any points/code/aspects mentioned in this ticket, I would surely be glad to provide more information.

I would greatly appreciate if you could take a bit of time to look into the patch and give me your feedback/opinion on this documentation request.

Any feedback, testing, changes, recommendations would be highly appreciated.
Thanks in advance.

#3 metatag-n1862818-3.patch1.91 KBDamienMcKenna
PASSED: [[SimpleTest]]: [MySQL] 11 pass(es). View
#2 metatag-document-hook_metatag_config_default-1862818-2.patch2.16 KBDYdave
PASSED: [[SimpleTest]]: [MySQL] 11 pass(es). View
metatag-document-hook_metatag_config_default-0.patch2.16 KBDYdave
PASSED: [[SimpleTest]]: [MySQL] 11 pass(es). View
Members fund testing for the Drupal project. Drupal Association Learn more


DYdave’s picture

Status: Active » Needs review

Changing status for review.

Thanks very much in advance.

DYdave’s picture

2.16 KB
PASSED: [[SimpleTest]]: [MySQL] 11 pass(es). View

Quick coding standards update.
Fixed white-space at end of line.
Correct version attached as: metatag-document-hook_metatag_config_default-1862818-2.patch.

Thanks in advance for your feedback.

DamienMcKenna’s picture

1.91 KB
PASSED: [[SimpleTest]]: [MySQL] 11 pass(es). View

@DYdave: Thanks for the documentation, this is good stuff. This patch includes a few tiny improvements.

DamienMcKenna’s picture

Status: Needs review » Fixed


DYdave’s picture

Hi Damien,

Thanks a lot for your prompt reply, taking the time to clean up the patch (it looks really great now) and rolling that in (f930f41).

I would have loved to find something like that when I started working on #1856218: Add a default configuration for Views meta tags, so I hope it will save some time to other developers and that they will appreciate it.

I will keep working on the module and certainly continue contributing documentation, as I get to work closer with each API hooks.

Thanks again for your support and great work.

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

DamienMcKenna’s picture

Issue tags: -Metatags, -metatag