Welcome, Guest
Username: Password: Remember me

TOPIC: Different body class

Different body class 6 months 2 weeks ago #104725

  • Pulsor
  • Pulsor's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 5
  • Karma: 0
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!
The administrator has disabled public write access.

Different body class 6 months 2 weeks ago #104731

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4125
  • Thank you received: 761
  • Karma: 347
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.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.
The following user(s) said Thank You: Pulsor

Different body class 6 months 2 weeks ago #104765

  • Pulsor
  • Pulsor's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 5
  • Karma: 0
Thanks a lot! I will try this out and see how it goes.



Regards,
The administrator has disabled public write access.

Different body class 6 months 2 weeks ago #104785

  • Pulsor
  • Pulsor's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 5
  • Karma: 0
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!
The administrator has disabled public write access.

Different body class 6 months 2 weeks ago #104796

  • DenisChenu
  • DenisChenu's Avatar
  • OFFLINE
  • Moderator Lime
  • Posts: 6268
  • Thank you received: 800
  • Karma: 239
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)
The administrator has disabled public write access.
The following user(s) said Thank You: Pulsor

Different body class 6 months 2 weeks ago #104845

  • Pulsor
  • Pulsor's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 5
  • Karma: 0
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.
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.169 seconds
Donation Image