Change the background in function of the gender of the poster

Go down

Tutorial Change the background in function of the gender of the poster

Post by Shadow on October 9th 2012, 11:40 am

Change the background in function of the gender of the poster

1. Definition :

       So that this tip works, it is necessary that the field "gender" is visible in the messages profile and this, with a picture and not only the text ! We are going to create a CSS additional class fa_postbody_xy (for the boys) and fa_postbody_xx (for the girls) to the message body according to the informed gender, and with this new class, we'll be able to personalize the design of the post by manipulating its CSS.

       2. The codes :
Administration Panel Modules HTML & Javascript Javascript codes management
Create a new Javascript to apply "in the topics".

  • Title : (What you want)
  • Placement : in the topics
  • Javascript code :

    $(function() {
       //Indicate here the version of your forum.
       var version = "phpBB3";
       if(version.toLowerCase() == "phpbb2"){   
          $(".postdetails img[title='Male']").closest('.postdetails').parent('td').next('td').addClass("fa_postbody_xy");
          $(".postdetails img[title='Female']").closest('.postdetails').parent('td').next('td').addClass("fa_postbody_xx");
       }else if(version.toLowerCase() == "phpbb3"){   
          $(".postprofile img[title='Male']").closest('.postprofile').prev('.postbody').addClass("fa_postbody_xy");
          $(".postprofile img[title='Female']").closest('.postprofile').prev('.postbody').addClass("fa_postbody_xx");   
       }else if(version.toLowerCase() == "punbb"){   
          $(".user-info img[title='Male']").closest('.postmain').addClass("fa_postbody_xy");
          $(".user-info img[title='Female']").closest('.postmain').addClass("fa_postbody_xx");   
       }else if(version.toLowerCase() == "invision"){         
          $(".postprofile img[title='Male']").closest('.post-container').addClass("fa_postbody_xy");
          $(".postprofile img[title='Female']").closest('.post-container').addClass("fa_postbody_xx");

Important!: To make it works you absolutely need to indicate the version of your forum by editing the value of the variable version, you have the choice between phpBB2, phpBB3, punBB and Invision.

3. Personalization of the CSS :    

For example, here we have a CSS which act on the 2 classes that we have set up, thanks to the javascript  a background picture will be applied, different depending on your skill and your imagination. Smile  

Administration Panel Display Colors and pics Colors CSS stylesheet


   background: url("");
min-height: 500px;
.fa_postbody_xx {
   background: url("");
min-height: 500px;

4. The results :

It's done !  cheers  cheers  cheers


Male Posts : 16195
Reputation : 1791
Language : French, English

Back to top Go down

Back to top

Permissions in this forum:
You cannot reply to topics in this forum