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!

Related Questions

Generating a module instance from PHP

0  Asked on September 5, 2021 by ffrewin


Embed custom JS app in Joomla MVC

0  Asked on September 5, 2021 by miasto


Error when updating Gantry from 4.1.20 to 4.1.32

1  Asked on September 5, 2021 by norberto-gomes


Change user permissions programmatically on the fly

1  Asked on September 5, 2021 by aheavyobject


Akeeba backup update broke the site

2  Asked on September 5, 2021 by hamlet-kraskian


Proper way for autoloading in Joomla 4

1  Asked on September 5, 2021 by webchun


Menu Specifically For Super Users

1  Asked on September 5, 2021


Joomla PHP does not match host PHP

2  Asked on February 18, 2021


Controller Joomla – Output Class construct for color css style

1  Asked on February 5, 2021 by andrea-suriani


Joomla custom component – router not find alias

1  Asked on January 21, 2021 by lecraver


Joomla 3 call model function inside controller

3  Asked on December 28, 2020 by wbdevlop


Product url problem after updating VirtueMart

1  Asked on December 23, 2020 by kiasaty


Display intro image inside mod_breadcrumbs

0  Asked on November 11, 2020 by geoplous


Ask a Question

Get help from others!

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