Bienvenue, Invité
Nom d'utilisateur : Mot de passe : Se souvenir de moi

SUJET : Different body class

Different body class il y a 2 mois 1 semaine #104725

  • Pulsor
  • Portrait de Pulsor
  • Hors ligne
  • Fresh Lemon
  • Messages : 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!
L'administrateur a désactivé l'accès en écriture pour le public.

Different body class il y a 2 mois 1 semaine #104731

  • tpartner
  • Portrait de tpartner
  • Hors ligne
  • LimeSurvey Team
  • Messages : 3813
  • Remerciements reçus 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.
L'administrateur a désactivé l'accès en écriture pour le public.
Cet utilisateur a été remercié pour son message par: Pulsor

Different body class il y a 2 mois 1 semaine #104765

  • Pulsor
  • Portrait de Pulsor
  • Hors ligne
  • Fresh Lemon
  • Messages : 5
  • Karma: 0
Thanks a lot! I will try this out and see how it goes.



Regards,
L'administrateur a désactivé l'accès en écriture pour le public.

Different body class il y a 2 mois 1 semaine #104785

  • Pulsor
  • Portrait de Pulsor
  • Hors ligne
  • Fresh Lemon
  • Messages : 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!
L'administrateur a désactivé l'accès en écriture pour le public.

Different body class il y a 2 mois 1 semaine #104796

  • DenisChenu
  • Portrait de DenisChenu
  • Hors ligne
  • Moderator Lime
  • Messages : 5850
  • Remerciements reçus 716
  • 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)
L'administrateur a désactivé l'accès en écriture pour le public.
Cet utilisateur a été remercié pour son message par: Pulsor

Different body class il y a 2 mois 1 semaine #104845

  • Pulsor
  • Portrait de Pulsor
  • Hors ligne
  • Fresh Lemon
  • Messages : 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.
L'administrateur a désactivé l'accès en écriture pour le public.
Modérateurs: ITEd
Temps de génération de la page : 0.191 secondes
Donation Image