简体   繁体   English

如何在Drupal 8菜单项中添加额外的字段。 我想添加一个额外的图像字段

[英]How can I add an extra field in Drupal 8 menu Item. I want to add an extra image field

How can I add an extra field in Drupal 8 menu item? 如何在Drupal 8菜单项中添加额外的字段? I want to add an extra image field so that I can use that to display along with menu. 我想添加一个额外的图像字段,以便我可以使用它与菜单一起显示。

You can add it through code and then run update.php or drush command to updatedb. 您可以通过代码添加它,然后运行update.php或drush命令到updatedb。

You can check answers here: https://drupal.stackexchange.com/questions/205058/how-to-add-fields-to-menu-items 您可以在此处查看答案: https//drupal.stackexchange.com/questions/205058/how-to-add-fields-to-menu-items

Also check comments because I had some problems with that and I've left solution in comments. 还要检查评论,因为我遇到了一些问题,我在评论中留下了解决方案。

Check the Menu Item Extras module on Drupal.org projects site. 检查Drupal.org项目站点上的Menu Item Extras模块。 https://www.drupal.org/project/menu_item_extras https://www.drupal.org/project/menu_item_extras

But if you are looking for the harder way, you should manage differences in the rendering of menu items in the menu template, altering entity definition of menu_link_content entity using hook_entity_type_build() , altering menu_link_content form integrations such as node create\\edit form, override default menu item create form controller (there is provided property bundle with value menu_link_content by the default). 但是,如果你正在寻找更难的方式,你应该管理的菜单模板菜单项的呈现差异,改变的实体定义menu_link_content使用实体hook_entity_type_build() ,改变menu_link_content形式集成诸如node创建\\编辑形式,覆盖默认菜单项创建表单控制器(默认情况下提供的值为menu_link_content的属性包)。

It was not easy to extend menu item create/edit form using Field UI features because of the bug in Drupal core. 由于Drupal核心中的错误,使用Field UI功能扩展菜单项创建/编辑表单并不容易。 https://www.drupal.org/project/drupal/issues/2903161 But for now, the issue is solved. https://www.drupal.org/project/drupal/issues/2903161但是现在问题已经解决了。

So for now, you can manage that situation as with usual entity type. 所以现在,您可以像通常的实体类型一样管理这种情况。 https://drupal.stackexchange.com/q/222260/60214 or https://drupal.stackexchange.com/a/220463/60214 https://drupal.stackexchange.com/q/222260/60214https://drupal.stackexchange.com/a/220463/60214

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM