Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 06-08-2008, 07:27 PM
Razasharp's Avatar
Razasharp Razasharp is offline
 
Join Date: Feb 2005
Location: UK
Posts: 373
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Correct method to add extra fields to threads?

I am thinking about adding some extra fields for threads and wondered what you all thought was the best way to go about it.

Should I add the fields to the existing thread table, or create a new table for these fields?

There will be around 6 or 7, however, not all forums will be using them, actually just a handful. So for the majority of threads they won't be needed. Also, the info in these extra fields won't even show on showthread - they are being added for internal use only, hence their data will be called in a custom script. (Although they will be added/updated by mods or admin via edit thread)

Most of the hacks here add them to the thread table, however, some hacks like GARS create a separate table. Hence I wondered what you thought the best, most efficient method is.

Also, is the information in this thread still current?
Reply With Quote
  #2  
Old 06-08-2008, 07:33 PM
Paul M's Avatar
Paul M Paul M is offline
 
Join Date: Sep 2004
Location: Nottingham, UK
Posts: 23,748
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

From your description I would say create a new table with threadid as the key.
Reply With Quote
  #3  
Old 06-08-2008, 10:04 PM
Razasharp's Avatar
Razasharp Razasharp is offline
 
Join Date: Feb 2005
Location: UK
Posts: 373
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks Paul.

If you get two mins, can you give me some pointers or a rough outline on how I should go about it? I'll try to work out the details for myself (I'm still a php nube :lol
Reply With Quote
  #4  
Old 06-08-2008, 11:51 PM
harmor19 harmor19 is offline
 
Join Date: Apr 2005
Posts: 1,324
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Firstly think of the fields you like to use on your new table. Of course there's the ID, thread ID and the question. You should also put a field for enable/disable.

I made a similar hack and you can look at it to see what hooks you need to use. https://vborg.vbsupport.ru/showthread.php?t=128587

I suggest creating another table that holds the user's ID, the question ID and their answer.
If you know how to use 'LEFT JOIN' then you do not need to make a field for "thread ID" but since you do not know that much you should add "thread ID".
Reply With Quote
  #5  
Old 06-09-2008, 12:22 AM
Paul M's Avatar
Paul M Paul M is offline
 
Join Date: Sep 2004
Location: Nottingham, UK
Posts: 23,748
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Razasharp View Post
If you get two mins, can you give me some pointers or a rough outline on how I should go about it? I'll try to work out the details for myself (I'm still a php nube :lol
Can you be a bit more specific on what you want to know.
Reply With Quote
  #6  
Old 06-09-2008, 01:05 AM
Razasharp's Avatar
Razasharp Razasharp is offline
 
Join Date: Feb 2005
Location: UK
Posts: 373
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Harmor19 - thanks for the help (I think your hack works in a different way, whereby the 'fields' are actually forms, and the data entered simply gets appended to the post? If so any chance you doing one where the field data is stored in the db seperately? saves me the fuss and I could make a donation )

Paul - I was hoping for a general outline, but appreciate that's a bit too much to ask... prob easier if I post what I plan here and perhaps you guys can let me know if I'm on the right track or not?

So so far, I need a new table with fields. This seem ok? Have I missed anything? Do I need to index?

New table:
my_thread_fields

Fields:
ThreadID (key)
MYField 1
MYField 2
MYField 3
MYField 4
MYField 5
MYField 6
MYField 7

I will check out Harmor19's hack to see which bits are similar/I can learn from for the data to be input and updated through vB - I think this is where I'll get stuck the most!

Cheers,
Reply With Quote
  #7  
Old 06-09-2008, 12:56 PM
harmor19 harmor19 is offline
 
Join Date: Apr 2005
Posts: 1,324
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Razasharp View Post
Harmor19 - thanks for the help (I think your hack works in a different way, whereby the 'fields' are actually forms, and the data entered simply gets appended to the post? If so any chance you doing one where the field data is stored in the db seperately? saves me the fuss and I could make a donation )
As I said "I suggest creating another table that holds the user's ID, the question ID and their answer.
If you know how to use 'LEFT JOIN' then you do not need to make a field for "thread ID" but since you do not know that much you should add "thread ID"."

When an user edits their post call the table where the thread ID matches the thread ID in the table and where the user ID of the person browsing matches the user ID in the table.
Then you fill in the form question with the data received from said table.




New table:
my_thread_fields

Fields:
questionid (key)
ThreadID = (INT 20)
question (text)
status (tinyint 1) (to "show" or "hide" the question.)



New table:
my_thread_fields_answers

Fields:
answerid (key)
UserID (INT 40)
ThreadID = (INT 20)
questionid (INT 10)
Reply With Quote
  #8  
Old 06-10-2008, 12:57 AM
Razasharp's Avatar
Razasharp Razasharp is offline
 
Join Date: Feb 2005
Location: UK
Posts: 373
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks Andrew - I will give it a go and get back to the thread when I get stuck.

Cheers,
Reply With Quote
Reply


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 02:02 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.04362 seconds
  • Memory Usage 2,231KB
  • 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
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (8)post_thanks_box
  • (8)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (8)post_thanks_postbit_info
  • (8)postbit
  • (8)postbit_onlinestatus
  • (8)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