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.

Profile Fields Variables for Postprofile

3 posters

Go down

Solved Profile Fields Variables for Postprofile

Post by SirLaplace December 11th 2022, 9:14 pm

Me again,
Forum version: ModernBB

I'm looking for a way to separate and dissect custom profile fields from each other on the posts for so long, so that I can design them freely or move things around. I finally came across something like this in a discussion here, sent by @pedxz ,

https://ajuda.forumeiros.com/t117089-criacao-de-novas-variaveis

But this code is taking the value from the account that is logged in, if I'm not mistaken. I can use it to do things in mainpage or navbar or widgets etc. Is there a way to make it so that it takes the value from whoever have sent the post so that I can use this variable in the postprofile section? Currently, when I place the variable in the postprofile section, under the avatar, it gives the same value to each post, taking it from the logged in user.

I know next to nothing about javascript but I can imagine if it's possible to take this data from logged in user and since we have sections on topic lists like "last posts", there must be a way to get data from the poster too, this should be possible as well.

Thanks in advance.



Last edited by SirLaplace on December 20th 2022, 12:51 am; edited 1 time in total
SirLaplace
SirLaplace
Forumember

Male Posts : 50
Reputation : 4
Language : Turkish, English

http://innoctem.forum.st/

Back to top Go down

Solved Re: Profile Fields Variables for Postprofile

Post by tikky December 13th 2022, 5:21 pm

Hello @SirLaplace,

I can use this variable in the postprofile section
But any existing field in profile can be added to the messages

Profile Fields Variables for Postprofile Image76

What is your objective? Personalisation?
tikky
tikky
Forumember

Posts : 897
Reputation : 157
Language : 🇵🇹

https://www.forumotion.com/create-forum/modernbb

Back to top Go down

Solved Re: Profile Fields Variables for Postprofile

Post by SirLaplace December 13th 2022, 5:54 pm

@pedxz Yes, I know that but when I do that all fields are staying together as it is.

If I can create variables for each custom field, I can divide the fields into two boxes for instance.
Or I can keep some of the fields out of the box.
Or maybe I can create a field for people to place a personal gif URL and then I can code it so that it can show on another place on their posts.

These are just ideas, possibilities, I'm not asking for any of the particular situations I just want to know If we can do that Very Happy


Last edited by SirLaplace on December 20th 2022, 12:47 am; edited 1 time in total
SirLaplace
SirLaplace
Forumember

Male Posts : 50
Reputation : 4
Language : Turkish, English

http://innoctem.forum.st/

Back to top Go down

Solved Re: Profile Fields Variables for Postprofile

Post by tikky December 18th 2022, 10:53 pm

@SirLaplace: Use in topics this code
Code:
(function($) {
    'use strict';

    $(function() {


        $('.postprofile-name').each(function() {
            var $this = $(this);
            var $user = $this.find('a').attr('href');

            if (!$user.length) return;


            $.get($user, function(data) {
                $('dl[id^="field_id"]', data).each(function() {
                    const label = $(this)
                        .find('dt')
                        .text()
                        .toUpperCase()
                        .normalize('NFD')
                        .replace(/[\u0300-\u036f]/g, '')
                        .replace(/[^a-z0-9]+/gi, '-')
                        .replace(/^-|-$/gi, '');
                    const content = $(this).find('.field_uneditable').text();
                    const img = $(this).find('.field_uneditable > img');


                    $this.parents('.post').find('[data-user-field="' + label + '"]')
                        .replaceWith((/\bhttps?:\/\/\S*?\/[^\/.]+\.(jpg|png)\b/g.test(content) ? '<img src="' + content + '" alt="' + label + '" title="' + label + '" loading="lazy" style="max-width: 100%;" />' : img.attr('src') ? img.clone() : content));


                });
            });



        });




    });
}(jQuery));
The use is the same you just need added new elements between the
Code:
post
element
tikky
tikky
Forumember

Posts : 897
Reputation : 157
Language : 🇵🇹

https://www.forumotion.com/create-forum/modernbb

skouliki, Ape and SirLaplace like this post

Back to top Go down

Solved Re: Profile Fields Variables for Postprofile

Post by SirLaplace December 20th 2022, 12:51 am

@pedxz You are like a god to me. You don't know how long I tried to find something like this, make this happen. Thank you, thank you so very much. It works like a charm.
SirLaplace
SirLaplace
Forumember

Male Posts : 50
Reputation : 4
Language : Turkish, English

http://innoctem.forum.st/

Ape likes this post

Back to top Go down

Solved Re: Profile Fields Variables for Postprofile

Post by Ape December 20th 2022, 1:15 am

Problem solved & topic archived.
Please read our forum rules: ESF General Rules
@pedxz Thank you for your help.


Profile Fields Variables for Postprofile Left1212Profile Fields Variables for Postprofile Center11Profile Fields Variables for Postprofile Right112
Profile Fields Variables for Postprofile Ape_b110
Profile Fields Variables for Postprofile Ape1010
Ape
Ape
Administrator
Administrator

Male Posts : 19128
Reputation : 1993
Language : fluent in dork / mumbojumbo & English haha

http://chatworld.forumotion.co.uk/

Back to top Go down

Back to top

- Similar topics

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