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

Reply
 
Thread Tools Display Modes
  #1  
Old 04-25-2006, 05:11 PM
jaybolt jaybolt is offline
 
Join Date: Jun 2004
Location: UK
Posts: 20
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default How to add 2 custom fields to New Thread?

I am wanting to add two custom fields to new threads:

latitude
longitude

I want these stored in the thread table in VB

What I have tried:

1. Modified newthread template to include:
Code:
<!-- GOOGLE MAP COORDINATES START HERE -->
<fieldset class="fieldset">
<legend>$vbphrase[map_coordinates]</legend>
<div style="padding:$stylevar[formspacer]px">
<div><label for="latitude"><input type="text" class="bginput" size="5" name="latitude" value="$latitude" id="latitude" tabindex="1" /> $vbphrase[latitude]</label></div>
<br />
<div><label for="longitude"><input type="text" class="bginput" size="5" name="longitude" value="$longitude" id="longitude" tabindex="1" /> $vbphrase[longitude]</label></div>
</fieldset>
<!-- GOOGLE MAP COORDINATES END HERE -->
2. Added two new fields to the vb3_thread table - latitude (INT) and longitude (INT)

3. Created hooks in:

threadfpdata_start
Code:
$this->validfields['latitude'] = array(TYPE_INT, REQ_NO);
$this->validfields['longitude'] = array(TYPE_INT, REQ_NO);
newpost_process
Code:
$this->validfields['latitude'] = array(TYPE_INT, REQ_NO);
$this->validfields['longitude'] = array(TYPE_INT, REQ_NO);
newthread_post_start
Code:
$vbulletin->input->clean_array_gpc('p', array('latitude' => TYPE_INT, 'longitude', TYPE_INT));
$newpost['lattitude'] =& $vbulletin->GPC['latitude'];
$newpost['longitude'] =& $vbulletin->GPC['longitude'];
Obviously this isn't working so can anyone help me please? I have searched the forums and that is where I gathered the above information on the hooks and I copied some of the code in the newthread template to try and create the code above.

Thanks very much

Ok, I'm getting there. There is a typo in newpost_process

it now reads:

Code:
if ($type == 'thread')
{
    $dataman->setr('thread_dec_lat', $post['thread_dec_lat']);
    $dataman->setr('thread_dec_lon', $post['thread_dec_lon']);
}
It now writes the latitude field to vb_thread but not longitude

I've change the variable names from 'latitude' to 'thread_dec_lat' and 'longitude' to 'thread_dec_long' by the way

Now to figure out why it is only writing one of the variables into the database ...
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:54 AM.


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.08672 seconds
  • Memory Usage 2,160KB
  • Queries Executed 13 (?)
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
  • (5)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)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