The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.

PHP/JScript Question? : ID etc. Selector for Individual Profile Field

5 posters

Go down

Solved PHP/JScript Question? : ID etc. Selector for Individual Profile Field

Post by ElMuggs August 7th 2011, 8:36 am

Okay this is a bit of a curly question.

I've been working on toggling the profile field information shown under the avatar to save space on posts. I'm using punBB in this case on our testboard.

Now I have two fields that I want to always display.

you can see it working here with the show/hide button under the Avatar.

I want to set the Nationality icon and Race (Muggle) Icon to always display

should be pretty simple right?

Except that it involves having a unique ID for each field.
Which Forumotion's doesn't seem to have (though logically one must exist).

Anyone got any ideas?
ElMuggs
ElMuggs
Forumember

Posts : 91
Reputation : 17
Language : CSS / HTML / BBcode / Javascript / Graphics and Tech Support yeech..
Location : Deep in the belly of the code

http://wizardswb.forumotion.com

Back to top Go down

Solved Re: PHP/JScript Question? : ID etc. Selector for Individual Profile Field

Post by SLGray August 7th 2011, 8:39 am

Can you not just remove those two items from the code, so they appear?


PHP/JScript Question? : ID etc. Selector for Individual Profile Field Slgray10

When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.
SLGray
SLGray
Administrator
Administrator

Male Posts : 51567
Reputation : 3525
Language : English
Location : United States

https://forumsclub.com/gc/128-link-directory/

Back to top Go down

Solved Re: PHP/JScript Question? : ID etc. Selector for Individual Profile Field

Post by ElMuggs August 7th 2011, 9:09 am

I wish!

but the profile fields are all dynamically added though php (which can't be modified in the template). there's no way to separate them in the code.

The code is as follows:

Code:
   <div class="user-info toggle">
                        <!-- BEGIN profile_field -->
{postrow.displayed.profile_field.LABEL}{postrow.displayed.profile_field.CONTENT}{postrow.displayed.profile_field.SEPARATOR}
                        <!-- END profile_field -->
                        {postrow.displayed.POSTER_RPG}
                     </div>

Ideally there would be a field such as {postrow.displayed.profile_field.ID} but I've been using trial and error to find one without any luck.
ElMuggs
ElMuggs
Forumember

Posts : 91
Reputation : 17
Language : CSS / HTML / BBcode / Javascript / Graphics and Tech Support yeech..
Location : Deep in the belly of the code

http://wizardswb.forumotion.com

Back to top Go down

Solved Re: PHP/JScript Question? : ID etc. Selector for Individual Profile Field

Post by Darren1 August 7th 2011, 9:49 am

G'Evening Very Happy

That's the thing with our templates, there's alot that are either too closely links so if u edit it, it screw the other over, or it's all mashed into 1 code so u can't edit it TT

I'm not aware of a code, or way that's able to do what you wish.
Darren1
Darren1
Helper
Helper

Male Posts : 11853
Reputation : 566
Language : English

Back to top Go down

Solved Re: PHP/JScript Question? : ID etc. Selector for Individual Profile Field

Post by ElMuggs August 7th 2011, 11:18 am

Cheers Darren, I wanted to know if i was overlooking anything before I started looking at some curly Javascript solutions Razz

Looks like it might be a case of finding a way to 'strip' the dirtycode from the label variable to create a id or somesuch. *sigh* fun fun.
ElMuggs
ElMuggs
Forumember

Posts : 91
Reputation : 17
Language : CSS / HTML / BBcode / Javascript / Graphics and Tech Support yeech..
Location : Deep in the belly of the code

http://wizardswb.forumotion.com

Back to top Go down

Solved Re: PHP/JScript Question? : ID etc. Selector for Individual Profile Field

Post by Guest August 7th 2011, 9:02 pm

Change this:

Code:
<div class="user-info toggle">
<!-- BEGIN profile_field -->
    {postrow.displayed.profile_field.LABEL}{postrow.displayed.profile_field.CONTENT}{postrow.displayed.profile_field.SEPARATOR}
<!-- END profile_field -->
<div>
to this:

Code:
<!-- BEGIN profile_field -->
    <div class="profile-field">
        {postrow.displayed.profile_field.LABEL}{postrow.displayed.profile_field.CONTENT}
    </div>
<!-- END profile_field -->

<div class="user-info toggle"></div>

<script type="text/javascript>
(code to append profile fields to toggle DIV)
</script>
Each profile field will now be enclosed in a DIV tag with a class name. Since you know the order of the profile fields, all you need is a short script that appends the desired profile field DIVs into the toggle DIV.
avatar
Guest
Guest


Back to top Go down

Solved Re: PHP/JScript Question? : ID etc. Selector for Individual Profile Field

Post by ElMuggs August 8th 2011, 4:00 am

Thanks heaps!

but it still doesn't assign the class values

using <div class="profile-field"> just gives all of them a value of profile-field

figuring a typo i tried <div class={profile-field}> but all that did was give them a blank value.
ElMuggs
ElMuggs
Forumember

Posts : 91
Reputation : 17
Language : CSS / HTML / BBcode / Javascript / Graphics and Tech Support yeech..
Location : Deep in the belly of the code

http://wizardswb.forumotion.com

Back to top Go down

Solved Re: PHP/JScript Question? : ID etc. Selector for Individual Profile Field

Post by Mr.Rulez August 8th 2011, 4:28 am

How did you make your background green?
Mr.Rulez
Mr.Rulez
Forumember

Posts : 36
Reputation : 0
Language : English

Back to top Go down

Solved Re: PHP/JScript Question? : ID etc. Selector for Individual Profile Field

Post by ElMuggs August 8th 2011, 4:31 am

Green is from the THANKS button. Smile

and good news!

Turns out that everything between the comments seems to run for each profile field.

So writing a little javascript I was able to generate a counter and assign it to a span around the value.

It's not perfect but it works Very Happy

first you need to define i in the header.
simple as adding

Code:


<script type="text/javascript">
var i = 1;
</script>

then insert the javascript between profile_field.LABEL and CONTENTS
Code:
<!-- BEGIN profile_field -->
    <div class=profile_field>
        {postrow.displayed.profile_field.LABEL}

<script type="text/javascript">
i++;

var id = "a" + i;

document.write('<span id="'+id+'">');

</script>

{postrow.displayed.profile_field.CONTENT}</span>
    </div>
<!-- END profile_field -->

so this is solved Rolling Eyes
ElMuggs
ElMuggs
Forumember

Posts : 91
Reputation : 17
Language : CSS / HTML / BBcode / Javascript / Graphics and Tech Support yeech..
Location : Deep in the belly of the code

http://wizardswb.forumotion.com

Back to top Go down

Solved Re: PHP/JScript Question? : ID etc. Selector for Individual Profile Field

Post by kirk August 8th 2011, 5:14 am

cool stuff.

Since the topic now appares to be solved i will now mark and lock the thread.
kirk
kirk
Forumaster

Male Posts : 11037
Reputation : 653
Language : English,Vulcan,Klingon, Romulan,& Gorn

Back to top Go down

Back to top

- Similar topics

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