Support from Acquia helps fund testing for Drupal Acquia logo

Comments

xurizaemon’s picture

Thanks for stepping up! I've created an 8.x-1.x branch in git and a release (which we won't show until there's something committed).

Version hasn't shown up in the issue queue yet - not sure if I'm forgetting a step or it's just going to take time.

xurizaemon’s picture

Version: 7.x-1.x-dev » 8.x-1.x-dev
xurizaemon’s picture

Title: Drupal 8 version » Drupal 8 port for Menu Breadcrumb
ipo4ka704’s picture

Ok we will start. Later we will give a patch.

xurizaemon’s picture

Issue summary: View changes

ipo4ka704 if you want to get your work in progress somewhere visible that'd be cool - maybe a drupal.org sandbox or on a platform like github?

that way you might benefit from others who are keen to engage but don't know where they might start if they can't see your work

daylioti’s picture

Status: Active » Needs review
FileSize
37.45 KB

We (@InternetDevels team) have ported the first stage and made a patch.
But there are some defects that are associated with the fact that the kernel is not fully functional works adequately.
We plan to maintain this module in the future and want to get the maintainers.

xurizaemon’s picture

That's great - I'm totally open to additional maintainers and your enthusiasm is very welcome. Let's see how this contribution goes first?

Committed patch above to 8.x-1.x - it looks good at a quick scan & anything is better than nothing :)

Will leave at "Needs Review" for now.

Codenator’s picture

Created fully working sandbox module. If it the same functionally can add path there.
https://www.drupal.org/sandbox/oles89/2367919

Test your path igeat work but outdated.

Codenator’s picture

Status: Needs review » Needs work
choster’s picture

Thanks for the initial work. Changes in core since the post seem to have rendered it non-functional unfortunately. On a clean D8b9 install, enabling 8.x-1.x-dev kills the site with the message (paths redacted)

Recoverable fatal error: Argument 2 passed to menu_breadcrumb_system_breadcrumb_alter() must be of the type array, object given, called in /www/core/lib/Drupal/Core/Extension/ModuleHandler.php on line 494 and defined in menu_breadcrumb_system_breadcrumb_alter() (line 382 of modules/menu_breadcrumb/menu_breadcrumb.module).

The same error also prevents a clean pm-uninstall via drush; here is the trace (paths redacted):

#0 /www/modules/menu_breadcrumb/menu_breadcrumb.install(8): Drupal\Core\Config\ImmutableConfig->delete()
#1 [internal function]: menu_breadcrumb_uninstall()
#2 /www/core/lib/Drupal/Core/Extension/ModuleHandler.php(384): call_user_func_array('menu_breadcrumb...',
Array)
#3 /www/core/lib/Drupal/Core/Extension/ModuleInstaller.php(370):
Drupal\Core\Extension\ModuleHandler->invoke('menu_breadcrumb', 'uninstall')
#4
/www/sites/default/files/php/service_container/service_container_prod/8a456f2808c59685b7f282d3e560a115bb2e88d006c43f4456b8039e0fcff35f.php(8767):
Drupal\Core\Extension\ModuleInstaller->uninstall(Array, true)
#5 /~/.composer/vendor/drush/drush/commands/core/drupal/environment.inc(225):
Drupal\Core\DependencyInjection\Container\prod\Drupal_Core_Extension_ModuleInstaller_Proxy->uninstall(Array)
#6 /~/.composer/vendor/drush/drush/commands/core/drupal/pm_8.inc(80): drush_module_uninstall(Array)
#7 /~/.composer/vendor/drush/drush/commands/pm/pm.drush.inc(1190): _drush_pm_uninstall(Array)
#8 [internal function]: drush_pm_uninstall('menu_breadcrumb')
#9 /~/.composer/vendor/drush/drush/includes/command.inc(368): call_user_func_array('drush_pm_uninst...', Array)
#10 /~/.composer/vendor/drush/drush/includes/command.inc(219): _drush_invoke_hooks(Array, Array)
#11 [internal function]: drush_command('menu_breadcrumb')
#12 /~/.composer/vendor/drush/drush/includes/command.inc(187): call_user_func_array('drush_command', Array)
#13 /~/.composer/vendor/drush/drush/lib/Drush/Boot/BaseBoot.php(62): drush_dispatch(Array)
#14 /~/.composer/vendor/drush/drush/drush.php(70): Drush\Boot\BaseBoot->bootstrap_and_dispatch()
#15 /~/.composer/vendor/drush/drush/drush.php(11): drush_main()
#16 {main}
Codenator’s picture

Thanks for test module! Fixed for Drupal beta10!
Will be happy for any ideas how improve it! For now it is fully functional module.
Link to module https://www.drupal.org/sandbox/oles89/2367919
p.s. comment #11 you test very out dated module

Codenator’s picture

Status: Needs work » Needs review
rooby’s picture

I also have a sandbox module for something similar at https://www.drupal.org/sandbox/rooby/2709721

My module works more like Breadcrumbs by path in that it doesn't care about active trail/menu, it just looks at the path and tries to create a link for each path section if it finds one in the menu.

While it doesn't work the same as this module and it still has a little work to go it may have some code that is useful here so feel free to use any parts of it that may be useful.

berdyshev’s picture

Hi,

I have updated code of 8.x-1.x branch to work with latest Drupal 8 stable version.

  • All features from original 7.x module, except regular expressions for menu matching (not implemented yet, for now)
  • Additional options:
    • Disable for admin pages
    • Use site name for Home link

I have also pushed changes to sandbox https://www.drupal.org/sandbox/berdart/menu_breadcrumb_

Feedbacks and suggestions are welcome!

RyanPrice’s picture

Thank you @berdyshev for your efforts here. Hoping someone has time to test this in D8 in the near future. I won't be able to until next week sometime.

Appreciate the work.

temkin’s picture

Status: Needs review » Reviewed & tested by the community

I had a chance to test #15 on a Drupal 8 site and it worked fine. Thanks @berdyshev!

Marking as RTBC so that it can be merged into 8.x-dev branch.

Leksat’s picture

Tested #15, looks good!
+1 to commit this, so that we can file new bug-fixes :D

For example, when menu structure is changed, caches are not cleared.

But in general, #15 is good to go!

@berdyshev, thanks a lot!

berdyshev’s picture

Thanks a lot guys for your review.

I have re-rolled patch with some changes:

  • Rename some options to be self-explaining
  • Refactored breadcrumb builder — found more simple and optimal solution
RyanPrice’s picture

Status: Reviewed & tested by the community » Needs review

Just updating the status - if someone has time to test this new patch it would be appreciated.

acbramley’s picture

Taking a look at this now.

acbramley’s picture

+++ b/src/MenuBasedBreadcrumbBuilder.php
@@ -0,0 +1,144 @@
+    $this->config = $this->configFactory->getEditable('menu_breadcrumb.settings');

Shouldn't be using getEditable in a read context.

+++ b/src/MenuBasedBreadcrumbBuilder.php
@@ -0,0 +1,144 @@
+          ->getPath(), '/admin') !== 0

Checking if the path starts with "/admin" isn't a valid way of checking for an admin path.

See https://www.drupal.org/node/2224207

+++ b/src/Form/SettingsForm.php
@@ -0,0 +1,215 @@
+    array_walk($menus, function (&$menu, $menu_name) use ($menu_breadcrumb_menus) {
+      if (!empty($menu_breadcrumb_menus[$menu_name])) {
+        $menu = $menu_breadcrumb_menus[$menu_name] + ['label' => $menu];
+      }
+      else {
+        $menu = ['weight' => 0, 'enabled' => 0, 'label' => $menu];
+      }
+    });
+
+    uasort($menus, function ($a, $b) {
+      return SortArray::sortByWeightElement($a, $b);
+    });

Personal opinion: 2 anonymous functions in a row make this function highly unreadable.

I'm not sure why but there seems to be a shift towards anon functions in the Drupal community but I think it's better to go for readability/maintainability.

Other than that there's some coding standards violations, and a lack of tests but overall this is a solid effort. We'll probably be using this soon so I think this is a really good start and should be committed asap once the things above are fixed

berdyshev’s picture

Thanks for your review, @acbramley.

Yes there are a lot of things which could be improved and implemented, but I think this could be a minimal version we could proceed with.

I have fixed your suggestions, patch attached

acbramley’s picture

Status: Needs review » Reviewed & tested by the community

@berdyshev agreed, RTBC'd nice work!

  • RyanPrice committed eb3aa8f on 8.x-1.x authored by berdyshev
    Issue #2149577 by berdyshev: Drupal 8 port for Menu Breadcrumb
    
RyanPrice’s picture

Status: Reviewed & tested by the community » Closed (fixed)

Merged into 8.x-1.x

rphair’s picture

I understand this issue is closed and thank everyone for finally bringing this module to D8. While waiting I wrote my own implementation, working the same way in a basic sense (following the menu active trail) though it will also look for taxonomy memberships and extend the breadcrumb trail according to those (e.g., for Articles that aren't explicitly on a menu).

This is my first module and I would appreciate if anyone interested in better breadcrumbs for D8 would take a look at sandbox module Menu Breadcrumb with Attachment by Taxonomy. I would be thankful for any suggestions to make this module robust enough for general use.

acbramley’s picture

@rphair, I suggest instead of yet-another-breadcrumb-module you add a feature request to this module and patch it with the changes and configuration required to get your taxonomy attachment working.

rphair’s picture

thanks @acbramley - issue posted here: https://www.drupal.org/node/2754437

rphair’s picture

Hoping at least one of the maintainers will see this: since no movement on patches to bug reports submitted in last 3 months, have offered to take over maintenance of D8 branch (https://www.drupal.org/node/2810611): guidelines suggest responding to this request within 2 weeks. All these bug fixes have been ported into sandbox referred to in #27.

xurizaemon’s picture

@rphair - I see you're already added as maintainer, so please accept my blessing to engage the D8 branch :)

rphair’s picture

Thanks to both @xurizaemon and @RyanPrice for the positive response; I plan to clean up any loose ends resulting from the separate threads & upload the patched branch today...