Different body class

More
3 years 1 month ago #104725 by Pulsor
Hello Everyone,

I'm new here. I posted this on the Developer section too, since I don't know where to put it exactly.

I need to know if there's a way to add a code in the
<body class="default lang-{SURVEYLANGUAGE} {SURVEYFORMAT}">
(the body class line of startpage.pstpl).

What I'm trying to accomplish is to add different backgrounds: in the welcome page, question pages, and in the endpage.

If the answer's no, please be sure that the 'no' is definitive.


Thanks in advance guys!

Please Log in to join the conversation.

More
3 years 1 month ago #104731 by tpartner
A JavaScript solution...

Add this to the end of welcome.pstpl:
<script type="text/javascript" charset="utf-8">		
	$(document).ready(function(){
		$('body').addClass('welcome-page');
	});
</script>


And this to question.pstpl:
<script type="text/javascript" charset="utf-8">		
	$(document).ready(function(){
		$('body').addClass('welcome-page');
	});
</script>


And this to endpage.pstpl:
<script type="text/javascript" charset="utf-8">		
	$(document).ready(function(){
		$('body').addClass('end-page');
	});
</script>


.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: Pulsor

Please Log in to join the conversation.

More
3 years 1 month ago #104765 by Pulsor
Thanks a lot! I will try this out and see how it goes.



Regards,

Please Log in to join the conversation.

More
3 years 1 month ago #104785 by Pulsor
Ok, tried those codes and it seems to work. Thanks a lot tpartner! Now welcome page has its own body class, so does question and endpage. Now, I need to add a different body class per question-made page.

For example, my survey has 17 questions, so there's a total of 17 'pages'. I need every body of those to have a different class. I know that each questions has an identifier code, so maybe there's a way to get it and add it in the body class. I don't know.


Any ideas?



Thanks in advance!

Please Log in to join the conversation.

More
3 years 1 month ago #104796 by DenisChenu
Hi,

Activate "show question code" in survey settings, remove the default part with {QCODE} in question.pdtpl, and add this:
<script type="text/javascript" charset="utf-8">		
$(document).ready(function(){$('body').addClass({QCODE});});
</script>
(same than tpartner code)

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).
The following user(s) said Thank You: Pulsor

Please Log in to join the conversation.

More
3 years 1 month ago #104845 by Pulsor
Thanks DenisChenu, the js seems to work just fine! Tho I had to add {QUESTION_CODE} instead of {QCODE}. Guess it's my LS version. Also, had to put '' between that code.

Btw, about tpartner code, I've added the 'end-page' script on completed.pstpl instead of endpage.pstpl, since welcome and endpage files are related. When I changed the body bg in the beginning, it was the same at the end (which I didn't wanted).


Thanks again both of you guys, you've been a great help! And sorry for my english heh.

Please Log in to join the conversation.