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.
The forum of the forums
5 posters

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

    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

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

    Post by ElMuggs Sun 7 Aug 2011 - 8:36

    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?
    SLGray
    SLGray
    Administrator
    Administrator


    Male Posts : 51554
    Reputation : 3524
    Language : English
    Location : United States

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

    Post by SLGray Sun 7 Aug 2011 - 8:39

    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.
    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

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

    Post by ElMuggs Sun 7 Aug 2011 - 9:09

    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.
    Darren1
    Darren1
    Helper
    Helper


    Male Posts : 11853
    Reputation : 566
    Language : English

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

    Post by Darren1 Sun 7 Aug 2011 - 9:49

    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.
    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

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

    Post by ElMuggs Sun 7 Aug 2011 - 11:18

    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.
    avatar
    Guest
    Guest


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

    Post by Guest Sun 7 Aug 2011 - 21:02

    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.
    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

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

    Post by ElMuggs Mon 8 Aug 2011 - 4:00

    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.
    Mr.Rulez
    Mr.Rulez
    Forumember


    Posts : 36
    Reputation : 0
    Language : English

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

    Post by Mr.Rulez Mon 8 Aug 2011 - 4:28

    How did you make your background green?
    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

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

    Post by ElMuggs Mon 8 Aug 2011 - 4:31

    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
    kirk
    kirk
    Forumaster


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

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

    Post by kirk Mon 8 Aug 2011 - 5:14

    cool stuff.

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

      Current date/time is Wed 13 Nov 2024 - 17:50