Willkommen, Gast
Benutzername: Passwort: Angemeldet bleiben:

THEMA: Different body class

Different body class 2 Monate 1 Woche her #104725

  • Pulsor
  • Pulsors Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 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!
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Different body class 2 Monate 1 Woche her #104731

  • tpartner
  • tpartners Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 3813
  • Dank erhalten: 683
  • Karma: 328
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.
Der Administrator hat öffentliche Schreibrechte deaktiviert.
Folgende Benutzer bedankten sich: Pulsor

Different body class 2 Monate 1 Woche her #104765

  • Pulsor
  • Pulsors Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 5
  • Karma: 0
Thanks a lot! I will try this out and see how it goes.



Regards,
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Different body class 2 Monate 1 Woche her #104785

  • Pulsor
  • Pulsors Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 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!
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Different body class 2 Monate 1 Woche her #104796

  • DenisChenu
  • DenisChenus Avatar
  • OFFLINE
  • Moderator Lime
  • Beiträge: 5838
  • Dank erhalten: 714
  • Karma: 222
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)
Der Administrator hat öffentliche Schreibrechte deaktiviert.
Folgende Benutzer bedankten sich: Pulsor

Different body class 2 Monate 1 Woche her #104845

  • Pulsor
  • Pulsors Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 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.
Der Administrator hat öffentliche Schreibrechte deaktiviert.
Moderatoren: ITEd
Ladezeit der Seite: 0.196 Sekunden
Donation Image