Skip to content

Commit e96227f

Browse files
committed
Automatically set selected current one on highscores filters
1 parent c49c9d9 commit e96227f

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

system/pages/highscores.php

+5-3
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,12 @@
3535
$configVocations = config('vocations');
3636
$configVocationsAmount = config('vocations_amount');
3737

38-
if($settingHighscoresVocationBox && $vocation !== 'all')
39-
{
38+
$vocationId = null;
39+
if($settingHighscoresVocationBox && $vocation !== 'all') {
4040
foreach($configVocations as $id => $name) {
4141
if(strtolower($name) == $vocation) {
42-
$add_vocs = array($id);
42+
$vocationId = $id;
43+
$add_vocs = [$id];
4344

4445
$i = $id + $configVocationsAmount;
4546
while(isset($configVocations[$i])) {
@@ -287,6 +288,7 @@
287288
'skillName' => ($skill == SKILL_FRAGS ? 'Frags' : ($skill == SKILL_BALANCE ? 'Balance' : getSkillName($skill))),
288289
'levelName' => ($skill != SKILL_FRAGS && $skill != SKILL_BALANCE ? 'Level' : ($skill == SKILL_BALANCE ? 'Balance' : 'Frags')),
289290
'vocation' => $vocation !== 'all' ? $vocation : null,
291+
'vocationId' => $vocationId,
290292
'types' => $types,
291293
'linkPreviousPage' => $linkPreviousPage,
292294
'linkNextPage' => $linkNextPage,

system/templates/highscores.html.twig

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<select onchange="location = this.value;" aria-label="skillFilter" id="skillFilter">
1212
{% set i = 0 %}
1313
{% for link, name in types %}
14-
<option value="{{ getLink('highscores') }}/{{ link }}{% if vocation is not null %}{{ vocation }}{% endif %}" class="size_xs">{{ name }}</option>
14+
<option value="{{ getLink('highscores') }}/{{ link }}/{% if vocation is not null %}{{ vocation }}{% endif %}" class="size_xs" {% if list is not null and list == link %}selected{% endif %}>{{ name }}</option>
1515
{% endfor %}
1616
</select>
1717
</td>
@@ -21,7 +21,7 @@
2121
<option value="{{ getLink('highscores') }}/{{ list }}" class="size_xs">[ALL]</option>
2222
{% set i = 0 %}
2323
{% for i in 1..config.vocations_amount %}
24-
<option value="{{ getLink('highscores') }}/{{ list }}/{{ config.vocations[i]|lower }}" class="size_xs">{{ config.vocations[i]}}</option>
24+
<option value="{{ getLink('highscores') }}/{{ list }}/{{ config.vocations[i]|lower }}" class="size_xs" {% if vocationId is not null and vocationId == i %}selected{% endif %}>{{ config.vocations[i]}}</option>
2525
{% endfor %}
2626
</select>
2727
</td>

0 commit comments

Comments
 (0)