Place the last of profile fields above post message Hitskin_logo Hitskin.com

This is a Hitskin.com skin preview
Install the skinReturn to the skin page

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

    Place the last of profile fields above post message

    LeChat
    LeChat
    Forumember


    Posts : 39
    Reputation : 1
    Language : english, polish

    Solved Place the last of profile fields above post message

    Post by LeChat Tue Oct 24, 2023 2:44 pm

    Technical Details


    Forum version : #phpBB3
    Position : Founder
    Forum link : https://mayo.forumpolish.com/

    Description of problem

    I wanna add a last of profile fields above a post (near to user name).

    Like here:
    Place the last of profile fields above post message FhK6rzW

    Is it possible to do that and keep the current fields layout?


    Last edited by LeChat on Thu Oct 26, 2023 12:48 pm; edited 1 time in total
    Razor12345
    Razor12345
    Support Moderator
    Support Moderator


    Male Posts : 1539
    Reputation : 266
    Language : Ukr, Rus, Eng
    Location : Ukraine

    Solved Re: Place the last of profile fields above post message

    Post by Razor12345 Wed Oct 25, 2023 8:14 am

    Good afternoon!

    Since you have heavily modified templates, I can't test the code on my test forum and use developer tools.

    1) You need to create a field that will be displayed in the user's profile (AP - Users & Groups - Profiles)
    For the demonstration, I will use your existing field - Multikonta.

    2) You need to change the viewtopic_body template
    Find the code fragment that is responsible for displaying the block with the class
    Code:
    headpost
    .
    In this block, add the following code:

    Code:
    <div class="special__element"></div>

    Place the last of profile fields above post message Scree467

    3) AP - Modules - Javascript codes management - Create new JavaScript
    Title: any
    Placement: In the topics
    Code:

    Code:

    $(document).ready(function() {
    const listOfPosts = document.querySelectorAll('.post');

    listOfPosts.forEach((item) => {
        const campoPElements = item.querySelectorAll('.pto-dentro .campo-p');
        const lastCampoElements = campoPElements[campoPElements.length - 1];
    const layoutSpecialElement = item.querySelector('.special__element');
        if (lastCampoElements && layoutSpecialElement) {
                const spesialElementTitle = lastCampoElements.querySelector('.campp-label').textContent;

    if (spesialElementTitle === 'Multikonta : ') {
           
            const specialElement = lastCampoElements.querySelector('.campp-cont').innerHTML;

        layoutSpecialElement.append(specialElement);
        lastCampoElements.style.display = 'none';

        }
        }
    });
    });

    Save. Result:

    Before:

    Place the last of profile fields above post message Scree468

    After:

    Place the last of profile fields above post message Scree469

    Important!
    1) The profile field, which will be outside the information block, should be the last field in the users' profile.
    2) This line of code checks for the presence of the field in the profile
    Code:
    if (spesialElementTitle === 'Multikonta : ') {

    The string in quotes must match the name of the field in the profile.



    Place the last of profile fields above post message Screen51

    SarkZKalie likes this post

    LeChat
    LeChat
    Forumember


    Posts : 39
    Reputation : 1
    Language : english, polish

    Solved Re: Place the last of profile fields above post message

    Post by LeChat Wed Oct 25, 2023 2:50 pm

    Thank you, I tried to do that, but I think I must did something wrong. Can you check it on Jayden Ray profile?
    Razor12345
    Razor12345
    Support Moderator
    Support Moderator


    Male Posts : 1539
    Reputation : 266
    Language : Ukr, Rus, Eng
    Location : Ukraine

    Solved Re: Place the last of profile fields above post message

    Post by Razor12345 Wed Oct 25, 2023 3:39 pm

    Send me the login and password for the admin account by private message, please.
    I don't see any errors in the console that are related to this code.

    I'll look into this issue tomorrow



    Place the last of profile fields above post message Screen51
    Razor12345
    Razor12345
    Support Moderator
    Support Moderator


    Male Posts : 1539
    Reputation : 266
    Language : Ukr, Rus, Eng
    Location : Ukraine

    Solved Re: Place the last of profile fields above post message

    Post by Razor12345 Thu Oct 26, 2023 3:49 am

    I changed the logic a bit and added an additional check

    Result:

    Place the last of profile fields above post message Scree471

    If you need help styling this area, let me know.



    Place the last of profile fields above post message Screen51
    LeChat
    LeChat
    Forumember


    Posts : 39
    Reputation : 1
    Language : english, polish

    Solved Re: Place the last of profile fields above post message

    Post by LeChat Thu Oct 26, 2023 12:48 pm

    I styled it myself.
    Place the last of profile fields above post message OuPBUW2

    Thank you for your help. <3

    Razor12345 likes this post

    skouliki
    skouliki
    Manager
    Manager


    Female Posts : 15269
    Reputation : 1701
    Language : English,Greek
    Location : Greece

    Solved Re: Place the last of profile fields above post message

    Post by skouliki Thu Oct 26, 2023 1:02 pm

    Problem solved & topic archived.
    Please read our forum rules: ESF General Rules