The forum of the forums
Welcome to the Official Support Forum of Forumotion!

To take full advantage of everything offered by our forum, please log in if you are already a member, or join our community if you've not yet.



Create a free forum like this one.

Post profile fields

View previous topic View next topic Go down

Solved Post profile fields

Post by the_rocketeer on April 21st 2015, 11:14 am

Hey peeps!

I was wondering if post profile fields can be named like this on phpBB2. Is it possible?  scratch

the_rocketeer
New Member

Female Posts : 19
Reputation : 1
Language : Bulgarian
Location : Europe

http://love-you-hogwarts.forumy.biz/

Back to top Go down

Solved Re: Post profile fields

Post by Ange Tuteur on April 21st 2015, 5:22 pm

Hello @the_rocketeer,

Yes, it's possible by modifying the templates.
( Display > Templates > General > viewtopic_body )

Find the profile fields :
Code:
            <!-- BEGIN profile_field -->
            {postrow.displayed.profile_field.LABEL} {postrow.displayed.profile_field.CONTENT}{postrow.displayed.profile_field.SEPARATOR}
            <!-- END profile_field -->

and wrap them with the tag you want, for example :
Code:
            <!-- BEGIN profile_field -->
            <span class="profileField">{postrow.displayed.profile_field.LABEL} {postrow.displayed.profile_field.CONTENT}{postrow.displayed.profile_field.SEPARATOR}</span>
            <!-- END profile_field -->

Ange Tuteur
Forumaster

Male Posts : 13021
Reputation : 2683
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

Solved Re: Post profile fields

Post by the_rocketeer on April 21st 2015, 11:24 pm

@Ange Tuteur wrote:Hello @the_rocketeer,

Yes, it's possible by modifying the templates.
( Display > Templates > General > viewtopic_body )

Find the profile fields :
Code:
            <!-- BEGIN profile_field -->
            {postrow.displayed.profile_field.LABEL} {postrow.displayed.profile_field.CONTENT}{postrow.displayed.profile_field.SEPARATOR}
            <!-- END profile_field -->

and wrap them with the tag you want, for example :
Code:
            <!-- BEGIN profile_field -->
            <span class="profileField">{postrow.displayed.profile_field.LABEL} {postrow.displayed.profile_field.CONTENT}{postrow.displayed.profile_field.SEPARATOR}</span>
            <!-- END profile_field -->

Hi @Ange Tuteur!

First, thank you so much for your help!  I love you
Second, i've done this already and fields got the same name so i can't customize them one by one. Is it possible to give them different names? Example

the_rocketeer
New Member

Female Posts : 19
Reputation : 1
Language : Bulgarian
Location : Europe

http://love-you-hogwarts.forumy.biz/

Back to top Go down

Solved Re: Post profile fields

Post by Ange Tuteur on April 22nd 2015, 12:24 am

This can be done by looping the profile fields and checking their label names. Go to Modules > JavaScript codes management > Create a new script

Placement : In the topics
Code:
$(function() {
  for (var a = document.getElementsByTagName('SPAN'), i = 0, j = a.length, label; i<j; i++) {
   
    if (/profileField/.test(a[i].className)) {
      label = a[i].innerHTML.replace(/<.*?>/g,'').replace(/:.*$/,'').replace(/^\s+|\s+$/g,'');
     
      switch (label) {
       
        case 'Posts' :
          a[i].className += ' field-posts';
          break;
         
        case 'Reputation' :
          a[i].className += ' field-reputation';
          break;
         
      }
     
    }
   
  }
});

Explanation :

I'm using a switch to check and apply the class. There's two examples ; Posts and Reputation. The switch looks like this :
Code:
      switch (label) {
       
        case 'Posts' :
          a[i].className += ' field-posts';
          break;
         
        case 'Reputation' :
          a[i].className += ' field-reputation';
          break;
         
      }

If the label name is equal to Posts or Reputation, it'll be applied with one of the two classes. You can add as many cases as needed, just make sure they're structured properly, like the following code.
Code:
case 'Example' : // Example being the name of your profile field
  a[i].className += ' field-example'; // the classname you want to apply to this field
  break; // break from the switch



I can then style the fields as I wish.. Smile
Code:
.field-posts { color:red }
.field-posts .label { color:blue }

.field-reputation { color:blue }
.field-reputation .label { color:red }

Ange Tuteur
Forumaster

Male Posts : 13021
Reputation : 2683
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

Solved Re: Post profile fields

Post by the_rocketeer on April 22nd 2015, 2:20 am

Ok, this is exactly what I'm looking for! 
I followed your instructions and changed posts for join date and reputation for motto but it doesn't work for me. :/ 
What am I doing wrong? Link

Javascript
Code:
$(function() {
  for (var a = document.getElementsByTagName('SPAN'), i = 0, j = a.length, label; i<j; i++) {
   
    if (/profileField/.test(a[i].className)) {
      label = a[i].innerHTML.replace(/<.*?>/g,'').replace(/:.*$/,'').replace(/^\s+|\s+$/g,'');
     
      switch (label) {
       
        case 'Join date' :
          a[i].className += ' field-join';
          break;
         
        case 'Motto' :
          a[i].className += ' field-motto';
          break;
         
      }
     
    }
   
  }
});

CSS
Code:
.field-motto { color:blue }
.field-motto .label { color:red }
.field-join { color:red }
.field-join .label { color:blue }

the_rocketeer
New Member

Female Posts : 19
Reputation : 1
Language : Bulgarian
Location : Europe

http://love-you-hogwarts.forumy.biz/

Back to top Go down

Solved Re: Post profile fields

Post by Ange Tuteur on April 22nd 2015, 2:27 am

Oh, I forgot to mention that you should apply the modification in this post. After that it should work. thumright

Ange Tuteur
Forumaster

Male Posts : 13021
Reputation : 2683
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

Solved Re: Post profile fields

Post by the_rocketeer on April 22nd 2015, 2:49 am

Oh, COOL!  ùù Finally it woooorks!
I have one more question. How does this work if field display type is not text but icon. I added one more field for exaple on my website.  Embarassed

the_rocketeer
New Member

Female Posts : 19
Reputation : 1
Language : Bulgarian
Location : Europe

http://love-you-hogwarts.forumy.biz/

Back to top Go down

Solved Re: Post profile fields

Post by Ange Tuteur on April 22nd 2015, 6:02 pm

You're right, with no label it'll be hard to determine what the field is. I was thinking of adding fallback values, first with the image source, and finally a field value, but I think I have a solution. The labels should always be visible so you can determine what that field is, but if you don't want to display the label for that field ( only the icon ) you can hide it with CSS.

For example :
Code:
.field-motto .label { display:none }

This will hide the label on motto making it appear that you chose the display type "icon"

Ange Tuteur
Forumaster

Male Posts : 13021
Reputation : 2683
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

Solved Re: Post profile fields

Post by the_rocketeer on April 22nd 2015, 9:11 pm

You're right, this is the best solution!
No words can describe how grateful I am! Thank you for the help, @Ange TuteurI love you I love you
Problem solved!  banana

the_rocketeer
New Member

Female Posts : 19
Reputation : 1
Language : Bulgarian
Location : Europe

http://love-you-hogwarts.forumy.biz/

Back to top Go down

Solved Re: Post profile fields

Post by Ange Tuteur on April 22nd 2015, 9:27 pm

You're welcome ^^

Topic archived

Have a nice day. Smile

Ange Tuteur
Forumaster

Male Posts : 13021
Reputation : 2683
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

View previous topic View next topic Back to top


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