Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 How to give a field a default value
JimR Offline
Junior Member
**
Posts: 15
Joined: Jun 2012
Post: #1
How to give a field a default value
odd ask I know but how ever here it is
I want to add a default value to a thread field by way of a database query
an example

PHP Code:
1
2
3
4
5
6
7
8
9
10
11
12
$select=$db->query("select * from ".TABLE_PREFIX."threadfields_data where tid ='".$post['tid']."'");
$num_rows = $db->num_rows($select); //rows for the record only 1 or 0
// if no row format the address
switch ($num_rows){
	case 0:
		// no record add the default address to the collection address fields
		$GLOBALS['threadfields']['add1']['value'] == $sub.$build;
		break;
	case 1:
		// do nothing
		break;
}

the variables $sub & $build have already been defined and need to become the default.
Currently I am inculding a php file within the template which defines my variables however with this I get parse errors am I putting the code in the wrong place ... does it need to be placed in a plugin that calls a hook before xthreads ?

02-26-2013 05:11 AM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #2
RE: How to give a field a default value
Parse error = your code is invalid regardless of where you put it.
I don't understand what your code is trying to do, more specifically, I don't understand the purpose of the database query.  If my guess is correct, you'd just put the following in the Default Value field:

Code:
<?=$sub.$build?>


My Blog
02-26-2013 09:30 AM
Find all posts by this user Quote this message in a reply
JimR Offline
Junior Member
**
Posts: 15
Joined: Jun 2012
Post: #3
RE: How to give a field a default value
(02-26-2013 09:30 AM)ZiNgA BuRgA Wrote:  Parse error = your code is invalid regardless of where you put it.
I don't understand what your code is trying to do, more specifically, I don't understand the purpose of the database query.  If my guess is correct, you'd just put the following in the Default Value field:

Code:
<?=$sub.$build?>


That didn't work however here is the postbit template

Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php
include "llpg.php";
?>
{$ignore_bit}
<a name="pid{$post['pid']}" id="pid{$post['pid']}"></a>
<table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder" colspan="4">
<tr class="menu">
			<td class="tcat tab at" title="Overview" style="cursor: pointer; text-align: center; width: 10%;border-right:1px solid black" abbr="tc1">
				<center><b>Overview</b></center>
			</td>
                            <td class="tab tcat" title="Garden Waste" style="cursor: pointer; text-align: center; width: 10%;border-right:1px solid black" abbr="tc2">
				<center><b>Garden Waste</b></center></td>
                              <td class="tcat tab" title="Commercial" style="cursor: pointer; text-align: center; width: 10%;border-right:1px solid black" abbr="tc3"><center><b>Commercial</b></center></td>
                               <td class="tcat tab" title="Notes"  style="cursor: pointer; text-align: center; width: 10%;border-right:1px solid black" abbr="tc4"><center><b>Notes</b></center></td>
				
                              <td class="tcat" width="60%">
			</td></tr></table>
<div id="tc1" class="content tbar">
<table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder" colspan="4">
<tr>
<td class="tbar" valign="top"></td>
<td class="tbar" rowspan="10" valign="top" style="margin-top:10px;margin-left:5px;"><center><b>Property Status</b></center>
<div style="float:left;padding-left:110px;">Single Person <input type="checkbox" name=mybox value="1" disabled checked><br>Garden Waste <input type="checkbox" name=mybox1 value="0" disabled ><br>Recycle Bin&nbsp; &nbsp;&nbsp;&nbsp;<input type="checkbox" name=mybox value="1" disabled checked></div>
</td></tr>
<tr><td class="tbar" width="50%"><b><div style ="margin-left:10px">Current Contact</b></div>{$GLOBALS['threadfields']['name']}</td></tr>
<tr><td class="tbar" width="50%"><b><div style="margin-left:10px">Official Address</div><div style="margin-left:10px"></b>$addressblock<br></div></td></tr>
<tr><td class="tbar" colspan="4" width="100%"><hr></td></tr>

</table>
</div>
<div id="tc2" class="content tbar">
<table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder" colspan="3">
<tr class="tbar"><td class="tbar"></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr class="tbar"><td colspan="2" width="35%" valign="top">
<div class="tbar" style="border:1px solid black;border-radius:0.3em;float:left;width:100%;padding:0px;"><center><b>Customer Information</b></center>
<div class="tinput"><b>Name :</b></div><div style="float:left;">{$GLOBALS['threadfields']['name']}</div>
<div class="tinput"><b>Telephone No :</b></div><div style="float:left;">{$GLOBALS['threadfields']['tele']}</div>
<div class="tinput"><b>Payment Method :</b> </div><div style="float:left;">{$GLOBALS['threadfields']['paym']}</div>
<div class="tinput"><b>Payment Reference :</b> </div><div style="float:left;">{$GLOBALS['threadfields']['cref']}</div>
<div class="tinput"><b>PIMM Reference Number :</b> </div><div style="float:left;">{$GLOBALS['threadfields']['pimm']}</div>
<div class="tinput" style="padding-bottom:5px"><b>Customer Account Number :</b> </div><div style="float:left;">{$GLOBALS['threadfields']['dnum']}</div>
</div></td>
<td colspan="4" valign="top"><div class="tbar" style="border:1px solid black;border-radius:0.3em;float:left;width:98%;padding:5px;"><b><center>Logistical Information</center></b>
<table style="clear:both"><tr><td valign="top"><center><b>Collection Address</b></center><div><center>[b]THE ADDRESS FROM THREADFIELDS WILL GO HERE[/b]</center></div></td>
<td valign="top"><center><b>Collection Tags</b></center></div><div style="float:right;margin-right:20px;">{$GLOBALS['threadfields']['gass']}</div><div style="float:right;margin-right:20px;"><b>Assisted Collection</b></div>
<br><div style="float:right;margin-right:20px;">{$GLOBALS['threadfields']['da']}</div><div style="float:right;margin-right:20px;"><b>Difficult Access</b></div><br>
<div style="float:right;margin-right:20px;">{$GLOBALS['threadfields']['prob']}</div><div style="float:right;margin-right:20px;"><b>Problem Collection</b></div><br>
<div style="float:right;margin-right:20px;">{$GLOBALS['threadfields']['numb']}</div><div style="float:right;margin-right:20px;"><b>Number Of Bins</b></div>
</td></tr></table>
</div></td></tr>
</table>
</div>
<div id ="tc3" class="content tbar">
<table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder" colspan="4">
<tr>
<td class="tbar" valign="top"><b>Commercial Waste Pane</b></td>
<td class="tbar" rowspan="10" valign="top" style="margin-top:10px;margin-left:5px;"><center><b>Collection Detail</b></center>
<div style="float:left;padding-left:110px;">Is Twat <input type="checkbox" name=mybox value="1" disabled checked><br>Side Waste <input type="checkbox" name=mybox1 value="0" disabled ></div
</td></tr>
<tr><td class="tbar" width="50%"><b><div style ="margin-left:10px">Contact&nbsp&nbsp&nbsp</div></td></tr>
<tr><td class="tbar" width="50%"><b><div style="margin-left:10px">Billing Address</div><div style="margin-left:10px"></b><br></div></td></tr>
<tr><td style="background:#cedba4;" colspan="2"><hr></td></tr>

</table>
</div>
<div id ="tc4" class="content tbar">
<div class="post {$unapproved_shade}" style="{$post_visibility}" id="post_{$post['pid']}">
<div class="post_content">
		<div class="post_body" id="pid_{$post['pid']}">
		{$post['message']}
	</div>
	{$post['attachments']}
	{$post['signature']}
	<div class="post_meta" id="post_meta_{$post['pid']}">
		{$post['iplogged']}
	</div>

</div>
</div>
</div>
<div class="tbar">
	<span class="tbar" style="padding-left:10px;">
		{$post['button_email']}{$post['button_edit']}</span>
	
	</div>
</div>


and here is llpg.php

PHP Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<?php
// llpg display functions
global $mybb, $db, $cache, $templates;
// pull the correct record from llpg table
$select=$db->query("select * from ".TABLE_PREFIX."llpg where NationalUPRN ='".$post['uprn']."'");
$result=$db->fetch_array($select);// can not fail as the field has to be populated and has been selected before
$sub = $result['SUBBUILDINGNAME'];
$build = $result['BUILDINGNAME']; 
$no = $result['BUILDINGNUMBER'];
$street = $result['STREETNAME'];
$local= $result['LOCALITYNAME'];
$town = $result['TOWN'];
$postcode= $result['POSTCODE'];
if ($mybb->settings['llpg_addressblock']==1) // do this if required N.B the single address lines are also returned
{
// produce a preformatted address
if ($sub <> null or $build <> null){$build=$build."<br>";} // add a br is populated
if ($no==null and $street == null and $local == null){$split=0;} // no option
if ($no<>null and $street == null and $local == null){$split=1;} // just house number
if ($no==null and $street <> null and $local == null){$split=2;} // just a street name
if ($no==null and $street == null and $local <> null){$split=3;} // just locality
if ($no<>null and $street == null and $local <> null){$split=4;} // number and locality
if ($no<>null and $street <> null and $local == null){$split=5;} // number and street
if ($no==null and $street <> null and $loacl <> null){$split=6;} // street and locality
if ($no <> null and $street <> null and $local <> null){$split=7;} // all 3
if ($sub <> null and $build <> null and $no == null){$split=8;} // commercial units ??
if ($sub == null and $build <> null and $street == null and $local == null){$split=9;}
if ($sub == null and $build <> null and $no == null and $local == null and $street <> null) {$street=$street."<br>";}
if ($sub <> null and $build <> null and $no == null and $local == null and $street <> null) {$street=$street."<br>";}
if ($sub == null and $no == null and $local == null and $street <> null) {$street= $result['STREETNAME'];}
//if ($sub <> null and $build <> null and $no <> null and $street <> null and $local == null) {}
switch ($split){ 
case 0:
// nothing presented just do the format
$sub=$sub."<br>";
break;
case 1:
die("case1");
// this can not happen unless the table is crashed
break;
case 2:
$Street=$street."<br>";
$local=$local."<br>";
break;
case 3:
$local=$local."<br>";
break;
case 4:
$local=$local."<br>";
break;
case 5:
$street=$street."<br>";
break;
case 6:
die("street + local");
// should never hit
break;
case 7:
$street=$street."<br>";
$local=$local."<br>";
//die("all 3");
break;
case 8:
$sub=$sub."<br>";
// should never hit this
break;
case 9:
//die("nine");
//$build=$build."<br>";
break;
case 200:
//die("here it is");
break;
default:
die("not thought of"); 
// have I missed something ?
}
 
if ($sub <>""){
$sub=$sub.' '; // add a space
}
if ($no <>""){
$no." "; 
}
$position = strpos($town, ",",$position);// we have a comma
 if ($position > 0){$town = str_replace(",","<br>",$town);}// replace the comma with <br>
// format the block
$addressblock = "$sub $build $no $street $local $town<br>$postcode";
// $addressblock is now formatted and in the template
}
// now add the collection address to our fields
// test if there is a row 
$select=$db->query("select * from ".TABLE_PREFIX."threadfields_data where tid ='".$post['tid']."'");
$num_rows = $db->num_rows($select); //rows for the record only 1 or 0
// if no row format the address
switch ($num_rows){
	case 0:
// no record add the default address to the collection address fields
// from the llpg table                  		
		break;
	case 1:
		// do nothing
		
		break;
}


?>

what I am  trying to do is if there is no record in the threadfields_data table, make the threadfields default to the data from the llpg table but if there is a record in the threadfields_data table do nothing.
the only reason I have tried to do this is that I want to save my users some time by supplying a default address which they can edit (as required) or would it be better to pre process the thread_fields data table with the default addresses (put them all in), as I have 65500 posts I would perfer to add the data as required rather than pre process them

02-27-2013 02:49 AM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #4
RE: How to give a field a default value
Okay, so you want a Blank Replacement Value, not a Default Value.
In which case, you place the code there.

As for your PHP, you need to globalise your $sub and $build variables, otherwise nothing outside the template can actually access them.
You may wish to review your code though.  There's certainly stuff in there that you probably aren't intending, and the logic seems unnecessarily complicated.

My Blog
02-27-2013 09:31 AM
Find all posts by this user Quote this message in a reply
JimR Offline
Junior Member
**
Posts: 15
Joined: Jun 2012
Post: #5
RE: How to give a field a default value
(02-27-2013 09:31 AM)ZiNgA BuRgA Wrote:  Okay, so you want a Blank Replacement Value, not a Default Value.
In which case, you place the code there.

As for your PHP, you need to globalise your $sub and $build variables, otherwise nothing outside the template can actually access them.
You may wish to review your code though.  There's certainly stuff in there that you probably aren't intending, and the logic seems unnecessarily complicated.

The big switch statement is required the llpg database (this contains all UK addresses) has 200 fields of which none are required to be filled in (different entry clerks use different fields). in order to make things simple I have chosen the most popular fields. To make the address display without blank lines I took the approach of using the switch. unless you can advise me of a better way of doing it.
I tried to use the Blank Replacement Value which works when you use {$GLOBALS['threadfields']['add1']} in the postbit template but when you use {$tfinput['add1']} in the editpost template there is no value.
I have used a fresh install of mybb 1.69 with xthreads 1.62
produced a threadfield with the Default Value value set and this is not displayed when the post is edited I have also set a Blank Replacement Value should I only set one or the other ?
02-28-2013 04:10 AM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #6
RE: How to give a field a default value
Well, your PHP code is in postbit so of course it's not going to have any effect editpost/newthread.

My Blog
02-28-2013 09:52 AM
Find all posts by this user Quote this message in a reply
JimR Offline
Junior Member
**
Posts: 15
Joined: Jun 2012
Post: #7
RE: How to give a field a default value
(02-28-2013 09:52 AM)ZiNgA BuRgA Wrote:  Well, your PHP code is in postbit so of course it's not going to have any effect editpost/newthread.

here is edit post ... I do not use newthread at all

Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<?php
include "llpg.php";
?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="tabcontent.css" />
<title>{$mybb->settings['bbname']} - {$lang->edit_post}</title>
{$headerinclude}
<script type="text/javascript" src="jscripts/post.js?ver=1400"></script>
<script type="text/javascript" src="jscripts/post.js?ver=1400"></script>
<script type="text/javascript">jQuery.noConflict();</script>
</head>
<body> 
{$header}
{$post_errors}
{$attacherror}
<form action="editpost.php?pid={$pid}&amp;processed=1" method="post" enctype="multipart/form-data" name="input">
<input type="hidden" name="my_post_key" value="{$mybb->post_code}" />
<table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder" colspan="4">
<tr class="tbar">
			<td class="tcat tab at" title="Overview" style="cursor: pointer; text-align: center; width: 10%;border-right:1px solid #Cedfeb;" abbr="tc1">
				<center><b>Overview</b></center>
			</td>
                            <td class="tab tcat" title="Garden Waste" style="cursor: pointer; text-align: center; width: 10%;border-right:1px solid #Cedfeb;" abbr="tc2">
				<center><b>Garden Waste</b></center></td>
                              <td class="tcat tab" title="Commercial" style="cursor: pointer; text-align: center; width: 10%;border-right:1px solid #Cedfeb;" abbr="tc3"><center><b>Commercial</b></center></td>
                               <td class="tcat tab" title="Notes"  style="cursor: pointer; text-align: center; width: 10%;border-right:1px solid #Cedfeb;" abbr="tc4"><center><b>Notes</b></center></td>
				
                              <td class="tcat" width="60%">
			</td></tr></table>

<div id="tc1" class="content tbar">
<table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder" colspan="4">
<tr>
<td class="tbar" valign="top"></td>
<td class="tbar" rowspan="10" valign="top" style="margin-top:10px;margin-left:5px;"><center><b>Property Status</b></center>
<div style="float:left;padding-left:110px;">Single Person <input type="checkbox" name=mybox value="1" disabled checked><br>Garden Waste <input type="checkbox" name=mybox1 value="0" disabled ></div
</td></tr>
<tr><td class="tbar" width="50%"><b><div style ="margin-left:10px">Customer&nbsp&nbsp&nbsp</b><br>{$GLOBALS['threadfields']['name']}</div></td></tr>
<tr><td class="tbar" width="50%"><b><div style="margin-left:10px">Address</div><div style="margin-left:10px"></b>$addressblock</div></td></tr>
<tr><td class="tbar" width="50%"><hr></td></tr>
</table>
</div>
<div id="tc2" class="content">
<table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder" colspan="3">
<tr class="tbar"><td class="tbar"></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr class="tbar"><td colspan="2" width="35%" valign="top">
<div class="tbar" style="border:1px solid black;border-radius:0.3em;float:left;width:100%;padding:5px;"><center><b>Customer Information</b></center>
<div style="padding:5px;float:left;"><b>Name :</b></div><div style="padding:5px;float:left;">{$tfinput['name']}</div><br style="clear:both">
<div style="padding:5px;float:left;"><b>Telephone No :</b></div><div style="padding:5px;float:left;">{$tfinput['tele']}</div>
<div style="padding:5px;float:left;"><b>Payment Method :</b> </div><div style="padding:5px;float:left;">{$tfinput['paym']}</div>
<div style="padding:5px;float:left"><b>Payment Reference :</b> </div><div style="padding:5px;float:left;">{$tfinput['cref']}</div>
<div style="padding:5px;float:left"><b>PIMM Reference Number :</b> </div><div style="padding:5px;float:left;">{$tfinput['pimm']}</div>
<div style="padding:5px;float:left"><b>Customer Account Number :</b> </div><div style="padding:5px;float:left;">{$tfinput['dnum']}</div>
</div></td>
<td colspan="4" valign="top"><div class="tbar" style="border:1px solid black;border-radius:0.3em;float:left;width:98%;padding:5px;"><b><center>Logistical Information</center></b>
<table><tr><td valign="top"><center><b>Collection Address</b></center>
<center><div style ="padding-bottom:5px">{$tfinput['add1']}</div>
<div style= "padding-bottom:5px">{$tfinput['add2']}</div>
<div style ="padding-bottom:5px">{$tfinput['add3']}</div>
<div style="padding-bottom:5px">{$tfinput['add4']}</div>
<div style="padding-bottom:5px">{$tfinput['pcode']}</center></td>
<td valign="top"><center><b>Collection Tags</b></center>
<div style="float:right;margin-right:20px;padding-bottom:1px;clear:both;"><b>In Scheme </b> {$tfinput['gcan']}</div>
<div style="float:right;margin-right:20px;padding-bottom:1px;clear:both;">{$tfinput['gass']}</div>
<div style="float:right;margin-right:20px;padding-bottom:1px;clear:both;">{$tfinput['da']}</div>

<div style="float:right;margin-right:20px;padding-bottom:1px;clear:both;">{$tfinput['gcoll']}</div>
<div style="float:right;margin-right:20px;padding-bottom:1px;clear:both;">{$tfinput['gnew']}</div>
<br>
</td></tr>
<tr><td colspan="2"><hr><br><div style="float:left;margin-right:20px;">{$tfinput['numb']}</div><div style="float:left;margin-right:20px;"><b>Collection Day</b></div><div  style="float:left;margin-right:20px;">{$tfinput['gcold']}</div><div style="float:left;margin-right:20px;"><b>Collection Order</b></div>{$tfinput['gcolord']}</td></tr>

</table>
</div></td></tr>
<tr class="tbar"><td class="tbar" colspan="2" width="35%"><div class="tbar" style="border:1px solid black;border-radius:0.3em;float:left;width:100%;padding:5px;margin-top:-40px;"><div style="padding:5px;"><center><a href="#" class="button"> Map </a> <a href="#" class="button">Streetview</a> <a href="#" class="button">Find Day</a>
<a href="#" class="button">Find Order</a> <a href="#" class="button">Print Letter</a>
</center></div></div></td><td class="tbar" colspan="4"></td></tr>
</table>
</div>
<div id="tc4" class="content">
<table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder" colspan="4">
<tr><td class="tbar"><textarea name="message" id="message" rows="20" cols="120" tabindex="28">{$message}</textarea>
{$codebuttons}</td></tr>
</table> 
</div>
<div class="tbar"><br>
<div align="center" class="tbar" ><input type="submit" class="button" name="submit" value="Update" tabindex="23" accesskey="s" /> </div>
<input type="hidden" name="action" value="do_editpost" />
<input type="hidden" name="posthash" value="{$posthash}" />
<input type="hidden" name="attachmentaid" value="" />
<input type="hidden" name="attachmentact" value="" />
</form>
<br>
</div>
{$footer}
</body>
</html>

as you will see I have included the same file (llpg.php) within editpost template.... so with my fresh install of mybb
I defined a threadfield like so :
Title - address1
key - add1
Input Type - textbox
Default Value - test value
all the other option are left at default
the editpost template is

Code:
<div style ="padding-bottom:5px">{$tfinput['add1']}</div>

(yes that is all that is in this template) and still do not get any text (I expected to see "test value") in the threadfield ... what have I done wrong ?

03-01-2013 01:31 AM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #8
RE: How to give a field a default value
Okay, I think I might be understanding you a bit more...
Is it the case that you already have a bunch of threads, but don't have this data set in the thread fields (ie you installed XThreads (or created the thread fields) after the threads were posted)?  If so, then you'd want to enter the data into all the thread fields, either manually or using a script (that just fills the database rows).  Doing anything to editpost makes no sense here.

Otherwise the Default Value will not appear on editpost, since it ultimately is just a default that gets entered when creating a thread.  When you've already got a thread, the value has been explicitly set by the thread, so a default makes no sense.

My Blog
03-01-2013 01:46 PM
Find all posts by this user Quote this message in a reply
JimR Offline
Junior Member
**
Posts: 15
Joined: Jun 2012
Post: #9
RE: How to give a field a default value
(03-01-2013 01:46 PM)ZiNgA BuRgA Wrote:  Okay, I think I might be understanding you a bit more...
Is it the case that you already have a bunch of threads, but don't have this data set in the thread fields (ie you installed XThreads (or created the thread fields) after the threads were posted)?  If so, then you'd want to enter the data into all the thread fields, either manually or using a script (that just fills the database rows).  Doing anything to editpost makes no sense here.

Otherwise the Default Value will not appear on editpost, since it ultimately is just a default that gets entered when creating a thread.  When you've already got a thread, the value has been explicitly set by the thread, so a default makes no sense.

Yes I have 65000 threads that I created with a script (I did forget to populate threadfields_data table Ouch ) so is the best answer to create a script that just adds the data I want to the threadfields data table ? Rather than the way I looked at it which was to display the data (if there was no record in threadfields_data table) or add the data if someone edits the post.
03-02-2013 02:40 AM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #10
RE: How to give a field a default value
Yes, it's almost always better to staticly do these things so that you don't complicate runtime logic.

My Blog
03-02-2013 11:12 AM
Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

 Standard Tools
Forum Jump: