diff --git a/src/Controller/BooktreeController.php b/src/Controller/BooktreeController.php index 44e5502..30b0e17 100644 --- a/src/Controller/BooktreeController.php +++ b/src/Controller/BooktreeController.php @@ -23,11 +23,21 @@ class BooktreeController extends ControllerBase { \Drupal::logger('booktree')->debug("Generated content for booktree"); + $pos_nid = 2; + $pos_depth = 3; + $pos_trim_length = 4; + $first_segment = $path_args[1]; + if (strlen($first_segment) == 2 && is_string($first_segment)) { + // There is a two letter language prefix in the path. + $pos_nid = 3; + $pos_depth = 4; + $pos_trim = 5; + } - if (isset($path_args[2])) { - $booktree_start = $path_args[2]; - $maxricursione = (isset($path_args[3])) ? $path_args[3] + 2 : \Drupal::config('booktree.settings')->get('booktree_deep')+2; - $trimval = (isset($path_args[4])) ? $path_args[4] : 256; + if (isset($path_args[$pos_nid])) { + $booktree_start = $path_args[$pos_nid]; + $maxricursione = (isset($path_args[$pos_depth])) ? $path_args[$pos_depth] + 2 : \Drupal::config('booktree.settings')->get('booktree_deep')+2; + $trimval = (isset($path_args[$pos_trim])) ? $path_args[$pos_trim] : 256; } else { $booktree_start = \Drupal::config('booktree.settings')->get('booktree_start');