Skip to content

Commit 136a800

Browse files
author
Wazabii
committed
Nesting slug
1 parent ba16fee commit 136a800

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

Builder.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class Builder
3434
private $select = 0;
3535
private $hideEmpty = false;
3636
private $count = 0;
37+
private $nestingSlug = false;
3738

3839
public function __construct($array)
3940
{
@@ -82,6 +83,17 @@ public function setMultiple(bool $bool): self
8283
return $this;
8384
}
8485

86+
/**
87+
* Activate nested slug e.g. "/slug1/slug2/slug3" instead of "/slug3"
88+
* @param boolean $bool
89+
* @return self
90+
*/
91+
public function nestingSlug($bool = true): self
92+
{
93+
$this->nestingSlug = $bool;
94+
return $this;
95+
}
96+
8597
/**
8698
* Set where item
8799
* @param array $arr
@@ -424,7 +436,7 @@ private function iterateStructure(int|false $mid, int $parent, callable $callbac
424436
$this->uri = array_merge($this->uriPrepend, $this->uri);
425437
}
426438
$this->uri[$id] = $this->permalink;
427-
$this->uriImp = "/" . implode("/", $this->uri);
439+
$this->uriImp = "/" . (($this->nestingSlug) ? implode("/", $this->uri) : $this->permalink);
428440

429441
// Save data
430442
$this->data[$id]['data'] = $this->uri;

0 commit comments

Comments
 (0)