Have an idea?

Visit Sawtooth Software Feedback to share your ideas on how we can improve our products.

Apply different stylesheet based on passed variable

I added some script to the settings tab (HEADER and HTML sections) to dynamically select a logo and style sheet to use based on a passed value. Works great when testing but when I upload the survey the correct logo is applied but not the correct style sheet. What's up with that?

Adding this to the HEADER section:
[% Begin Unverified Perl
my $a=VALUE("loc");
$a =~ s/\s+//;
if($a == 2)
{
return '<img src=' . GRAPHICSPATH() . 'XXXX.png' . ' border=\"0\">';

}
else
{
return '<img src=' . GRAPHICSPATH() . 'YYYYLogo.png' . ' border=\"0\">';

}

End Unverified %]


added this to the HTML section:

[% Begin Unverified Perl
my $a=VALUE("loc");
$a =~ s/\s+//;
if($a == 2)
{
return '<link rel="stylesheet" type="text/css" href="../../graphics/XXXX/XXXX.css">
<title>XXXX</title> 

';
}

else
{
return '<link rel="stylesheet" type="text/css" href="../../graphics/YYYY/YYYY.css">
<title>YYYY</title> 

';
}

End Unverified %]
asked Apr 22 by Chris Guth Bronze (780 points)

1 Answer

0 votes
 
Best answer
When Test Survey is ran, Lighthouse Studio creates a new "Test Survey" folder inside the normal study folder.  But to save on disk space, that folder isn't given its own graphics folder; it instead just uses the graphics folder one directory up from the .ssi.  When a questionnaire gets uploaded, the graphics folder is actually moved into the same directory as the .ssi.

Thus, the path "../../graphics/" makes sense in Test Survey, but you would actually need to use "../graphics/" when uploaded.  Alternatively, using the Sawtooth Script function GraphicsPath handles all this for you.
answered Apr 23 by Zachary Platinum Sawtooth Software, Inc. (114,750 points)
selected Apr 23 by Chris Guth
Thank you!  wasn't aware of that.
...