You cannot access the value of a pre-loaded question from the Welcome page.
So,for example, assume the following:
- The logo images are stored in the theme /files/ directory
- The welcome page is disabled
- The pre-loaded question is a single-choice with code Q1
- The pre-loaded question has answer codes A1...A5
Extend your theme and place something like this in the
nav_bar.twig file:
Code:
{% set imageNames = {
'A1': 'logo1.png',
'A2': 'logo2.png',
'A3': 'logo3.png',
'A4': 'logo4.png',
'A5': 'logo5.png'
}
%}
{% set imageAltTexts = {
'A1': 'Alt text 1',
'A2': 'Alt text 2',
'A3': 'Alt text 3',
'A4': 'Alt text 4',
'A5': 'Alt text 5'
}
%}
{% set imagePath = processString('{TEMPLATEURL}')~'files/' %}
{% set q1 = processString('{Q1}') %}
{% if('>' in processString('{Q1}')) %}
{% set q1 = processString('{Q1}')|split('>')[1]|split('<')[0] %}
{% endif %}
{% set imageName = imageNames[q1] %}
{% set imageSrc = imagePath~imageName %}
{% set imageAlt = imageAltTexts[q1] %}
<!-- Bootstrap Navigation Bar -->
{% if(aSurveyInfo.class.navbar) %}
<div class="{{ aSurveyInfo.class.navbar }} navbar-fixed-top" {{ aSurveyInfo.attr.navbar }}>
<div class="{{ aSurveyInfo.class.navbarheader }} " {{ aSurveyInfo.attr.navbarheader }} >
<button type="button" class="{{ aSurveyInfo.class.navbartoggle }}" {{ aSurveyInfo.attr.navbartoggle }} >
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
{# Logo option #}
{% if( aSurveyInfo.options.brandlogo == "on") %}
<div class="{{ aSurveyInfo.class.navbarbrand }} logo-container hidden-xs" {{ aSurveyInfo.attr.navbarbrand }} >
<img src="{{imageSrc}}" alt="{{imageAlt}}" class="logo img-responsive" />
</div>
{% else %}
<div class="{{ aSurveyInfo.class.navbarbrand }}" {{ aSurveyInfo.attr.navbarbrand }} >
{{ aSurveyInfo.name }}
</div>
{% endif %}
</div>
<div id="{{ aSurveyInfo.id.navbar }}" class="{{ aSurveyInfo.class.navbarcollapse }}" {{ aSurveyInfo.attr.navbarcollapse }} >
<ul class="{{ aSurveyInfo.class.navbarlink }} navbar-right" {{ aSurveyInfo.attr.navbarlink }}>
{{ include('./subviews/navigation/save_links.twig') }}
{{ include('./subviews/navigation/clearall_links.twig') }}
{{ include('./subviews/navigation/question_index_menu.twig') }}
{{ include('./subviews/navigation/language_changer_top_menu.twig') }}
</ul>
</div>
</div>
{% endif %}