In Drupal 7 and later, Entities are the central building block that makes up site. Many modules (such as Metatag) add functionality by associating their additional data with entities. By exposing Monster Menus pages as [read-only] entities, such modules can associate data with pages by mmtid with no special modifications required to either the module or Monster Menus.

Our particular need is to use the Metatag module to add various meta-tags to Monster Menus pages irrespective of the nodes placed on those pages. By exposing Monster Menus pages as Entities, the Metatag module can add its editing forms to the MM page-editing screens, associate its data with mmtids, and clean up its data on MM page delete.

Attached are 3 patches which implement aspects of this feature:

monster_menus-mm_entities.patch
This first patch adds just the bare essentials needed to support accessing Monster Menus pages as "mm_page" entities. This feature is primarily contained in a new "mm_entities" sub-module with the some very minor additions to mm_api.inc, misc.inc, mm_content.inc, and mm_ui_content_edit.inc that allow the mm_entities module to hook in at appropriate places in the content edit, delete, and render phases.

monster_menus-mm_entities_with_fields.patch
This patch is identical to the former one, but with the addition of an admin form for adding Fields to "mm_page" entities.

This is not a feature we require at this time, but I can imagine that it could be quite useful -- allowing site administrators to dynamically create additional page data or metadata options for site editors to work with.

monster_menus-mm_metatags.patch
This patch adds an additional tiny submodule that provides the integration configuration so that the Metatag module will know about "mm_page" entities. This may not be of interest for inclusion in MM proper, but I'm attaching it so that the other features can be tested and evaluated.

The patches above are usable, however they haven't been tried with a wide variety of modules (just Metatag and adding fields to pages). I'm interested in feedback on this proposed feature both broadly and on particular implementation details.

Best,
Adam

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Gribnif’s picture

Just a note: In D8, MM Pages will be full entities.

marcofernandes’s picture

I'm trying to use mm_metatags together with mm_entities. But the MM Page entity meta tags aren't rendered on page template. It always fetch the global meta tags.
Not sure if I missed any step when setting up MM Metatags. Basically I just enabled MM Page at admin/config/search/metatags/settings and added a new metatag entity at admin/config/search/metatags.

i.mcbride’s picture

The metatag module changed its API slightly since this issue was first created. I've rerolled the patch to add that sub-module from our current code. The significant change is the addition of a call to hook_metatag_entity_type_is_supported_alter(), which may be why MM pages are not showing up as an option.

marcofernandes’s picture

@i.mcbride at admin all is working properly and MM pages are shown as an option and I can set the metatags for the MM page.
The only issue is that is not rendering at page. I've checked the $content['metatags"] on page template and it's empty. So, not sure if I should do/add something at theme level.