Go Back   vb.org Archive > Community Discussions > Modification Requests/Questions (Unpaid)
  #1  
Old 06-04-2008, 12:29 PM
psylenced psylenced is offline
 
Join Date: May 2008
Posts: 33
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Custom Profile Field names

Is there any way of avoiding the sequential naming of custom profile fields?

I need to use them in my application, and they work perfectly for drop downs, radio, text and full text.

Only issue is the sequential naming.. eg field5, field6, field7, field8, etc. They will easily conflict with other applications and never will be the same name.

Is there a way of naming these better?

eg. field_plugin_abc_firstname, field_plugin_abc_lastname, etc..
Reply With Quote
  #2  
Old 06-05-2008, 05:33 AM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

No, they will always be numbered like this.
Reply With Quote
  #3  
Old 06-05-2008, 10:52 AM
Opserty Opserty is offline
 
Join Date: Apr 2007
Posts: 4,103
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Why not create some vBulletin Options that will enable you to set them? So you'd have
PHP Code:
$user[$vbulletin->options['firstfield']] 
. Might be a little messy but it is an easy solution.
Reply With Quote
  #4  
Old 06-06-2008, 02:03 AM
psylenced psylenced is offline
 
Join Date: May 2008
Posts: 33
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Just had a look through the code and they are pretty much hard coded.

eg.. 'field' + profilefieldid + '_blah';

I think it'd help a lot of mod devs if they were able to name these whatever they like (keeping the same naming system as a default) so there wouldnt be any conflicts and can add as many as they like.
Reply With Quote
  #5  
Old 06-06-2008, 02:14 AM
Reeve of shinra's Avatar
Reeve of shinra Reeve of shinra is offline
 
Join Date: Oct 2001
Location: NYC
Posts: 1,896
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

In the product, add a SQL query to add [name-of-field] to the userfield table. Then you can use $post[name-of-field] or $bbuserinfo[name-of-field] wherever vb calls profile fields.
Reply With Quote
  #6  
Old 06-06-2008, 02:15 AM
GameWizard's Avatar
GameWizard GameWizard is offline
 
Join Date: Apr 2004
Location: Vancouver, BC
Posts: 319
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Pardon my ignorance on this topic, but in case you haven't already tried. Try to find mods that already offer similar functionality and see how they worked around this problem, assuming a solution is even there.
Reply With Quote
  #7  
Old 06-06-2008, 05:15 AM
psylenced psylenced is offline
 
Join Date: May 2008
Posts: 33
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The issue is for my mod i need 20-30 profile fields, all diff types (text, full text, radio and drop down), all user-editable. I can approach it one of 3 main ways.

1 - Leave it using numbered profile fields which requires a lot of messing around and makes it possibly conflict with existing mods and hard to configure/install (if i decide to release it for other people).

2 - Edit the profile system to allow named fields. This affects a few different places and will require updating the core code every vb update which will probably more work than the former.

3 - Create my own database table/fields. This has no conflicts, except i'm duplicating all the existing profile field code which is exactly suited to what i need (groups, types, values, etc).

There isn't really an elegant way. Best case scenario would be for vb to update their code and support named fields officially. This would be perfect as mod authors can then use these fields very easily throughout their plugins and have no conflicts at all. Cant see a negative for that one.

Not sure of any other ways as i've only been developing for vb for a little over a week lol. Still trying to get my head around the code and way it goes about things after deciding to move to this platform.
Reply With Quote
  #8  
Old 06-06-2008, 02:25 PM
Opserty Opserty is offline
 
Join Date: Apr 2007
Posts: 4,103
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

If you are using 20-30 profile fields either extend the user table or create your own table which would include the fields & a userid reference.

I think the Custom profile fields are only really intended enable people with little understanding of PHP & MySQL to be able to create extra information fields without messing up their entire board.

However if you are going to add 20+ fields you will be better off creating another table (or extending the user one) and then using a JOIN to fetch the data. (I think there is a hook in fetch_userinfo, but don't quote me on it)
Reply With Quote
  #9  
Old 06-07-2008, 03:17 PM
psylenced psylenced is offline
 
Join Date: May 2008
Posts: 33
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I managed to get passed my specific issue (not the general question though), by going about it a different way.

My main problem was that i had profile field categories on my page, but they werent ajax editable (except in about me), but i wanted them separate.

I managed to change the code to allow this, but the issue was that there werent any hooks that would allow me to change this without modifying vb code. I needed to change the prepare_output function in ProfileFields.

I solved this by adding the following code to the member_build_blocks_start hook:

PHP Code:
class vb_ProfileBlock_ProfileFields2 extends vB_ProfileBlock_ProfileFields
{
    function 
prepare_output($id ''$options = array()) 
   {
         
// new code
   
}

Then re-running the profile block code to inherit the new class instead:

PHP Code:
foreach ($profileblock->locations AS $profilecategoryid => $location)
{
    if (
$location)
    {
        
$blocklist["profile_cat$profilecategoryid"] = array(
            
'class'         => 'ProfileFields2'
So my main problem was solved. Starting to get the hang of this too which is good, as i'm generally not a php coder.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 11:39 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.10996 seconds
  • Memory Usage 2,240KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (3)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (9)post_thanks_box
  • (9)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (9)post_thanks_postbit_info
  • (9)postbit
  • (9)postbit_onlinestatus
  • (9)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete