TransWikia.com

Add field to menu settings to output open graph image

Joomla Asked by Mano Meter on December 30, 2021

I want to add a media-field to the menus settings to pick an image for each menu item and output this as open graph images. I see two options:

  1. I add the field to the tab "Metadata" which then will be outputted via librariessrcDocumentRendererHtmlHeadRenderer.php. But i do not know where i can add fields to that tab.
  2. I add the field in my custom (category blog) layout xml-file and then somehow get it in my template index.php but i do not know how to get access to the field there and documentation says:
    "Note that if you add new parameters, these can be used in the layout file but will not be used in the core model or view files."
    Would i somehow have to put my field in the layout file to use it in my index.php?

One Answer

To add the fields to the com_menus item Metadata tab, you would need to write a content plugin to inject the fields.

Your Option 2 sounds clunky. In this case, I expect you would need to create a new filed in your category layout xml, then instantiate menus, loop through categories and insert into the menu based on the category IDs. Option 1 is the go-to solution for this problem.

Answered by Grant G on December 30, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP