Ich will die Navigationsbar dauerhaft einblenden. Dafür habe ich Navigation(); auf jeder Seite gesetzt. Allerdings werden in der Navigationsbar nur die Kapitel angezeigt. Jetzt hätte ich gerne, dass das Kapitel weiterhin markiert wird mit currentPage, wenn man sich durch die Fragen dieses Kapitels clicked.
EDIT:
Im großen und ganzen habe ich den Code von hier verwendet:
https://www.soscisurvey.de/help/doku.php/de:create:navigation
Unter PHP-Funktionen:
function navigation() {
// Completion check
$cKontakt = (count(array_merge(
checkItem('A001', 'A002_01'),
checkQst('A002', [1])
)) === 0);
$cStudium = (count(array_merge(
checkItem('S101_01', 'S102_01'),
checkQst('S101', [1]),
checkQst('S102', [1])
)) === 0);
$cFamilie = (
(value('F101') > 0) and
(value('F102') > 0)
);
$cGesellschaft = (
(value('G101') > 0)
);
html(
'<div style="border: 2px solid #CCCCCC; border-left: 0 none; border-right: 0 none; padding: 20px 0 12px 0; margin-bottom: 3em;">'.
'<div class="s2flex NavButtons" style="flex-wrap: wrap; margin-right: -8px">'.NL.
// Navigation
buttonToPage('Start').
buttonToPage('Kontakte', NULL, NULL, ($cKontakt ? 'complete' : 'incomplete')).
buttonToPage('Kontakte', NULL, NULL, (($abschnitt == 'contact') ? 'currentPage' : '')).
buttonToPage('Studium', NULL, NULL, ($cStudium ? 'complete' : 'incomplete')).
buttonToPage('Familie', NULL, NULL, ($cFamilie ? 'complete' : 'incomplete')).
buttonToPage('Gesellschaft', NULL, NULL, ($cGesellschaft ? 'complete' : 'incomplete')).
'<div style="width: 2em;"></div>'.
buttonToPage('abschicken').
'</div>'.
'</div>'
);
option('nextbutton', 'Nächstes Formular');
}
function checkQst($qID, $items) {
$fail = [];
foreach ($items as $item) {
$answer = value(id($qID, $item));
if (($answer < -3) or ($answer === '')) {
$text = preg_replace('/:.*/', '', getItemtext($qID, $item));
$fail[] = $text;
}
}
return $fail;
}
function checkItem($varIDs, $textID) {
$fail = [];
if (!is_array($varIDs)) {
$varIDs = [$varIDs];
}
foreach ($varIDs as $varID) {
$answer = value($varID);
if (($answer < -3) or ($answer === '')) {
$text = preg_replace('/:.*/', '', getItemtext($textID));
$fail[] = $text;
// Only one of them
break;
}
}
return $fail;
}
Und dann den Teil im Layout:
div.NavButtons button {
border: 2px solid %color.4%;
border-radius: 5px;
padding: 7px 6px;
margin-bottom: 8px;
flex-grow: 1;
margin-right: 8px;
}
div.NavButtons button.currentPage {
background-color: %color.4%;
color: white;
}
div.NavButtons button.complete:after { content: " \2713"; }
div.NavButtons button.incomplete:after { content: " \274C"; }
div.NavButtons button.currentPage:after { content: none; }
@media (min-width:1250px){
.NavButtons {
position: fixed;
top: 0;
left: 5px;
width: 200px;
height: 50%;
border-right: 2px solid #CCCCCC;
padding: 20px 0;
display: flex;
flex-direction: column;
box-sizing: border-box;
transition: transform 0.3s ease-in-out;
flex-grow: 1;
flex-shrink:1;
}
.buttonToPage {
padding: 10px 20px;
margin: 5px 0;
border: 1px solid #ccc;
background-color: #f0f0f0;
cursor: pointer;
text-align: left;
}
.container {
flex-grow: 1;
flex-shrink:1;
padding: 20px;
background-color: #fff;
display: flex;
flex: 1;
}
.content {
padding: 20px;
}
</style>