Skip to content

Commit c7582fb

Browse files
committed
Fix if config word_separator is not dash
Fixes #6
1 parent 9963129 commit c7582fb

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

system/expressionengine/third_party/structure_nav/libraries/Structure_nav_parser.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ public function get_variables($add_entry_vars = false)
5252

5353
$dom->loadHTML($html);
5454

55-
$ul = $dom->getElementById('nav-sub');
55+
$separator = ee()->config->item('word_separator') !== 'dash' ? '_' : '-';
56+
57+
$ul = $dom->getElementById('nav'.$separator.'sub');
5658

5759
$variables = $this->parse_ul($ul);
5860

@@ -371,13 +373,15 @@ protected function parse_ul(DOMElement $ul, $depth = 0)
371373

372374
$numLis = count($lis);
373375

376+
$separator = ee()->config->item('word_separator') !== 'dash' ? '_' : '-';
377+
374378
foreach ($lis as $i => $li)
375379
{
376380
$link = $li->firstChild;
377381

378382
$class = $li->getAttribute('class');
379383

380-
$entry_id = str_replace('nav-sub-', '', $li->getAttribute('id'));
384+
$entry_id = str_replace('nav'.$separator.'sub'.$separator, '', $li->getAttribute('id'));
381385

382386
$variables[$i] = array(
383387
'__prefix' => $prefix,
@@ -390,7 +394,7 @@ protected function parse_ul(DOMElement $ul, $depth = 0)
390394
$prefix.'count' => $i + 1,
391395
$prefix.'total_results' => $numLis,
392396
$prefix.'active' => !! preg_match('/\bhere\b/', $class),
393-
$prefix.'has_active_child' => !! preg_match('/\bparent-here\b/', $class),
397+
$prefix.'has_active_child' => !! preg_match('/\bparent'.$separator.'here\b/', $class),
394398
);
395399

396400
$childUl = $li->getElementsByTagName('ul')->item(0);

system/expressionengine/third_party/structure_nav/pi.structure_nav.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
$plugin_info = array(
1616
'pi_name' => 'Structure Nav',
17-
'pi_version' => '1.0.5',
17+
'pi_version' => '1.0.6',
1818
'pi_author' => 'rsanchez',
1919
'pi_author_url' => 'https://github.com/rsanchez',
2020
'pi_description'=> 'Tag pair for custom Structure navigation',

0 commit comments

Comments
 (0)