PDA

View Full Version : Mini Mods - Add custom field to postbit


Replicant
28 Nov 2015, 05:50
There have been a few questions regarding adding location to the postbit on vb.com lately. Lynne had a write-up here in 2013 using the Product/Hook system which is the best way to do it as the mod will survive an upgrade and there is a hook exactly where it's needed. I'm not going to go into creating a product with this mod.This is an example of a template edit to add a field to the postbit that only takes a few minutes. Keep in mid, this will be overwritten during an upgrade and will need to be re-applied. Since this requires editing templates, it will not work on the cloud. I am currently working on a jquery/ajax version for the cloud, but it's a little ways down the road when I'm not so busy.

Here's how to do it.
Step 1)Go to AdminCP >> User Profile fields >> Add new user profile field
Select single line textbox > then click "continue"
Fill out the title, description and other relevant info on that page and click save. This will also create the necessary phrases for the field.
Go to AdminCP >> User Profile fields >> User Profile fields Manager. Here you will see the new field you created and the field number used in step 2. I used field8 (Location) for this example.

Step 2) Edit conversation_userinfo template. Add this code after {vb:hook 'conversation_userstats'} on or about line 53 and click save.

Step 3) Goto your user profile and click edit settings. Scroll down on the profile tab and fill the new field with the info.


{vb:data postInfo, user, fetchProfileInfo, {vb:raw conversation.userid}}
<vb:if condition="$postInfo['field8']"><li><label>{vb:phrase field8_title}:</lable>
<span>{vb:raw postInfo.customFields.default.field8_title.val}</span></li>
</vb:if>


You can add classes in the code for custom CSS if you prefer. The default list view kind of sucks IMO.

faustvasea97
01 Dec 2015, 22:47
any photo ?

Replicant
04 Dec 2015, 06:29
any photo ?

I added one. Also fixed a typo in the code.

Rico300
06 Jan 2016, 16:35
Thx ;)

jkotlowski
08 Jan 2016, 13:16
Hi Replicant, I think this may be what I was looking for, but I'm not one hundred percent certain. Can this be used to add an image icon under a usertitle? And can that extra part in the postbit be assigned to specific usergroups only?

My members want to start doing "member of the year" awards, and a few are suggesting that the winners get small badges in their postbits for when they win a category. So I'd like to see if this is possible. :)

Replicant
08 Jan 2016, 20:48
Probably not without a custom coded product as these are user profile fields entered by the user. What you are looking for is an awards system that will need to be coded. Probably not too difficult to do. I'll look at it when I get some time or at least a hack to buy some time. With the hook system coming back, this may be easier to do but since it is in it's infancy, may be some time to wait until it's ready for production.

jkotlowski
08 Jan 2016, 23:23
Probably not without a custom coded product as these are user profile fields entered by the user. What you are looking for is an awards system that will need to be coded. Probably not too difficult to do. I'll look at it when I get some time or at least a hack to buy some time. With the hook system coming back, this may be easier to do but since it is in it's infancy, may be some time to wait until it's ready for production.

Thank you for the reply! If at any point in the future you could help, I'd appreciate it. (as I'm sure other VB5 members would!) :D

josueinaki
18 Jan 2016, 04:42
this is a good think, thanks for that.

Aros12
11 Feb 2016, 16:59
Thanks for the code Replicant but I could not get it to work. It shows "Location:" under some user's postbit but no location. My location is entered in my settings but doesn't show up in the postbit. I put the exact code above into my conversation_userinfo template at line 53 (field2 for me) but no go. Any ideas?

http://www.hobbysquawk.com/forum/rc-airplanes/beginner-q-a/30585-knowledgebase

Replicant
11 Feb 2016, 18:51
I pulled the fetchProfileInfo for your user at your site and the location info is there so its just not retrieving or getting translated at the template. I've not tested this on 5.2.0 so maybe that's the issue. I'll take a look at it and report back. Give me a day or so.
"field2_title":{"val":"Maple Valley, WA","hidden":"0"}

SOLVED:I fetched your template and found your issue. It's a typo. Change the 8 below to a 2 in your template and it should work.

{vb:data postInfo, user, fetchProfileInfo, {vb:raw conversation.userid}}
<vb:if condition="$postInfo['field2']"><li><label>{vb:phrase field2_title}:</lable>
<span>{vb:raw postInfo.customFields.default.field8_title.val}</span></li>
</vb:if>

Aros12
11 Feb 2016, 19:31
Okay thanks so much!

Aros12
12 Feb 2016, 20:52
You are the man! Thank you!!

IggyP
22 Feb 2016, 14:38
great thanks :)

mhere21
22 Mar 2016, 02:29
Exactly what I was looking for. Thank you.

KimK
11 Aug 2016, 22:00
I pulled the fetchProfileInfo for your user at your site and the location info is there so its just not retrieving or getting translated at the template. I've not tested this on 5.2.0 so maybe that's the issue. I'll take a look at it and report back. Give me a day or so.
"field2_title":{"val":"Maple Valley, WA","hidden":"0"}

SOLVED:I fetched your template and found your issue. It's a typo. Change the 8 below to a 2 in your template and it should work.

{vb:data postInfo, user, fetchProfileInfo, {vb:raw conversation.userid}}
<vb:if condition="$postInfo['field2']"><li><label>{vb:phrase field2_title}:</lable>
<span>{vb:raw postInfo.customFields.default.field8_title.val}</span></li>
</vb:if>

Hi Replicant, I am using vb 5.2.2 and tried the above, but it just translates into the field 2 title Location, without pulling the actual location the member entered. My hope is to actually bring in 2 fields, occupation and location. If you have a second, can you take a look? I didn't know if I was suppose to do anything with your first code block in this post, so that could be what I am doing wrong. My location field is 2, and I copied your code above to try the second time. www.Agentlinkus.com

I tried the update tools, because these are fields my members have already filled in, they are not new fields, and perhaps that is the problem. Running update tools didn't fix. Thank you so much.

Replicant
11 Aug 2016, 22:26
This modification is obsolete and cumbersome and was more or less a workaround until a proper mod was created. Noypiscripter has a mod that is far superior to this one and much easier to implement and is up to date. You can get it here (http://vbmods.rocks/forum/vbulletin-5-modifications/vbulletin-5-products-and-extensions/170-add-custom-profile-fields-in-postbit).

KimK
11 Aug 2016, 22:43
Thank you, I appreciate the direction =)

noypiscripter
15 Aug 2016, 06:03
This modification is obsolete and cumbersome and was more or less a workaround until a proper mod was created. Noypiscripter has a mod that is far superior to this one and much easier to implement and is up to date. You can get it here (http://vbmods.rocks/forum/vbulletin-5-modifications/vbulletin-5-products-and-extensions/170-add-custom-profile-fields-in-postbit).

Thanks Replicant! :)

spirit232
20 Sep 2017, 13:26
Many Thanks,

I am looking for the integration of the homepage from the profile page to the postbit