vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   How to add 2 custom fields to New Thread? (https://vborg.vbsupport.ru/showthread.php?t=114046)

jaybolt 04-25-2006 05:11 PM

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 ...


All times are GMT. The time now is 02:08 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.01056 seconds
  • Memory Usage 1,714KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (5)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (1)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete