【问题标题】:How to show all category items of menu in magento2如何在magento2中显示菜单的所有类别项
【发布时间】:2020-03-06 15:43:48
【问题描述】:

My phtml fileblock file codeall menu category data.output when I show data without using recursion upto two child category levels. output when I try to use recursion to show all child categories

实际上我需要在 magento 2 中创建超级菜单。所以我在模块块文件中使用集合获得导航类别数据,然后在模块 phtml 上。 现在我想使用 recusive foreach 循环显示导航类别标签名称。但它不起作用。当我不使用递归时,它会显示, 但是当我使用递归函数或数组函数数组行走时,它不起作用。我需要使用递归,以便它显示所有子类别的标签名称。 请帮忙。 我已经添加了我的块文件代码、Phtml 文件和模块前端输出的图像,请帮助。为什么递归不起作用?

【问题讨论】:

    标签: php html magento2


    【解决方案1】:

    我认为问题是

    当您不使用递归时,您会得到正确的结果数组结构(类别)。

    否则,你会得到错误的结构。

    我认为您可以 var_dump 数组以查看两种情况下的结构,然后进行比较。

    如果您是开发人员,那么您可以使用调试来查看数组的结构。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-01-05
      • 2016-02-28
      • 2020-03-20
      相关资源
      最近更新 更多