@@ -21,6 +21,11 @@ class BootstrapNavbarHelper extends Helper {
21
21
22
22
use BootstrapTrait;
23
23
24
+ /**
25
+ * Other helpers used by BootstrapNavbarHelper.
26
+ *
27
+ * @var array
28
+ */
24
29
public $ helpers = [
25
30
'Html ' ,
26
31
'Form ' => [
@@ -29,18 +34,19 @@ class BootstrapNavbarHelper extends Helper {
29
34
];
30
35
31
36
/**
32
- * Automatic detection of active link (`class="active"`) .
37
+ * Default configuration for the helper .
33
38
*
34
- * @var bool
35
- */
36
- public $ autoActiveLink = true ;
37
-
38
- /**
39
- * Automatic button link when not in a menu.
39
+ * - `autoActiveLink` Set to `true` to automatically add `active` class
40
+ * when given URL for a link matches the current URL. Default is `true`.
41
+ * - `autoButtonLink` Set to true` to automatically create buttons instead
42
+ * of links when outside a menu. Default is `true`.
40
43
*
41
- * @var bool
44
+ * @var array
42
45
*/
43
- public $ autoButtonLink = true ;
46
+ public $ _defaultConfig = [
47
+ 'autoActiveLink ' => true ,
48
+ 'autoButtonLink ' => true
49
+ ];
44
50
45
51
protected $ _fixed = false ;
46
52
protected $ _static = false ;
@@ -172,11 +178,12 @@ public function create($brand, $options = []) {
172
178
* @return string A HTML `<li>` tag wrapping the link.
173
179
*/
174
180
public function link ($ name , $ url = '' , array $ options = [], array $ linkOptions = []) {
175
- if ($ this ->_level == 0 && $ this ->autoButtonLink ) {
176
- $ options = $ this ->addClass ($ options , 'btn btn-default navbar-btn ' );
181
+ if ($ this ->_level == 0 && $ this ->config ('autoButtonLink ' )) {
182
+ $ options = $ this ->addClass ($ options , 'navbar-btn ' );
183
+ $ options = $ this ->addClass ($ options , 'btn btn-default ' );
177
184
return $ this ->Html ->link ($ name , $ url , $ options );
178
185
}
179
- if (Router::url () == Router::url ($ url ) && $ this ->autoActiveLink ) {
186
+ if (Router::url () == Router::url ($ url ) && $ this ->config ( ' autoActiveLink ' ) ) {
180
187
$ options = $ this ->addClass ($ options , 'active ' );
181
188
}
182
189
return $ this ->Html ->tag ('li ' , $ this ->Html ->link ($ name , $ url , $ linkOptions ),
0 commit comments