View Single Post
  #702  
Old 11-26-2007, 12:00 PM
grecostimpy grecostimpy is offline
 
Join Date: Mar 2005
Posts: 93
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Adding an additional custom field to Timeslips.


************NOTES************


This is an update of EvilLS1's instructions located HERE. His instructions were for vB Timeslip Database v2.1 (for the 3.0.X version of VBulletin). The instructions below update his very helpful post for use with the newest version of the vB Timeslip Database (v1.2) utilizing 3.68 PL2.

Adding an additional custom field to the Timeslips Database is a bit involved and due to the fact the original modification involves file edits, this addition does as well.

In the example used below, we are adding a single selection dropdown menu to add a field "Vehicle Color". Obviously, you can add any field you want, but make sure to change the specific answers and field names from the example below to suit your needs.

Also, (when reading the instructions below) please note that wherever you see "XX" on a file edit, you should be entering the fieldID # of the new custom profile field you created in place of "XX".

Files to Edit (3): member.php, timeslips.php, includes/functions_user.php
Templates to Edit (2): Timeslips, timeslipbit
Products to Edit (2): Update timeslips data, vehicledetails

As always, please backup your database and keep original copies of all modified files.


************CREATE NEW CUSTOM FIELD************


AdminCP > User Profile Fields > Add New User Profile Field

Choose Single-Selection Menu from the dropdown menu and click Continue

Fill out the profile form as follows (obviously replacing the profile field title, description and choices with your own)

Title: Vehicle Color
Description: Enter whatever description you would like
Profile Field Category: (Uncategorized)
Options: Separate each option with a new-line (carriage return):
Red
Blue
Green
Default Value: Leave blank
Max Length of allowed user input: 25
Field Length: 25
Display order: Whatever you want
Field Required: No
Field Editable by user: Yes
Private Field: No
Field Searchable on Members List: No
Show on Members List: No
Allow user to input their own value for this option: No
Max length of allowed user input: 25
Field Length: 25
Regular Expression: 0
Which page displays this option? Edit Profile

Save this new profile field and MAKE NOTE OF THE FIELD ID# in the User Profile Field Manager.


************FILE EDITS************


Open members.php

Find this line:

Code:
WHERE profilefieldid NOT IN (50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65) AND pf.form = 0 " . iif(!($permissions['genericpermissions'] & $vbulletin->bf_ugp_genericpermissions['canseehiddencustomfields']), "
Replace with this (replace XX with your new custom field number)

Code:
WHERE profilefieldid NOT IN (50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,XX) AND pf.form = 0 " . iif(!($permissions['genericpermissions'] & $vbulletin->bf_ugp_genericpermissions['canseehiddencustomfields']), "

Open includes/functions_user.php

Find this line:

Code:
WHERE profilefieldid NOT IN (50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65) AND editable IN (1,2)
Replace with this (replace XX with your new custom field number)

Code:
WHERE profilefieldid NOT IN (50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,XX) AND editable IN (1,2)

Open timeslips.php

Find this line:

Code:
$natasp='N/A';
Below it add this:

Code:
$red = 'Red';
$blue = 'Blue';
$green = 'Green';
Also in timeslips.php, find:

Code:
    else if ($_REQUEST['do'] == 'na') 
   {
        $condition.=" AND userfield.field65='" . addslashes($natasp) . "' AND userfield.field55>'".intval($number)."'";
        $cond.=" WHERE userfield.field65='" . addslashes($natasp) . "' AND userfield.field55>'".intval($number)."'";
        $orderby="userfield.field55";
        $direction=ASC;
        $bracket13="<b>[</b>";
        $bracket14="<b>]</b>";
   }

add BELOW (again, replacing XX with your custom field name and changing the blue colored text to match your profile field choices):

Code:
     else if ($_REQUEST['do'] == 'red') 
   {
        $condition.=" AND userfield.fieldXX='$red' AND userfield.field55>'".intval($number)."'";
        $cond.=" WHERE userfield.field55!=''";
        $orderby="userfield.field55";
        $direction=ASC;
        $bracket133="<b>[</b>";
        $bracket143="<b>]</b>";
   }
	      else if ($_REQUEST['do'] == 'blue') 
   {
        $condition.=" AND userfield.fieldXX='$blue' AND userfield.field55>'".intval($number)."'";
        $cond.=" WHERE userfield.field55!=''";
        $orderby="userfield.field55";
        $direction=ASC;
        $bracket133="<b>[</b>";
        $bracket143="<b>]</b>";
   }
	 	      else if ($_REQUEST['do'] == 'green') 
   {
        $condition.=" AND userfield.fieldXX='$green' AND userfield.field55>'".intval($number)."'";
        $cond.=" WHERE userfield.field55!=''";
        $orderby="userfield.field55";
        $direction=ASC;
        $bracket133="<b>[</b>";
        $bracket143="<b>]</b>";
   }

Still in timeslips.php, find this line:

Code:
$spacer=" - ";

and add the following below:

Code:
$color = "---";

also find this line:

Code:
$pos++;

and add this below it (again, replacing XX with your custom field name):

Code:
$color = $userinfo[fieldXX];

************TEMPLATE EDITS************


In your timeslips template find:

Code:
<td bgcolor="{categorybackcolor}" colspan="5" class="tcat"><b> Timeslip Database

Replace with

Code:
<td bgcolor="{categorybackcolor}" colspan="6" class="tcat"><b> Timeslip Database

find:

Code:
<option value="timeslips.php?$session[sessionurl]&do=na">N/A cars only</option>

add below it:

Code:
<option value="timeslips.php?$session[sessionurl]&do=red">Red</option>
<option value="timeslips.php?$session[sessionurl]&do=blue">Blue</option>
<option value="timeslips.php?$session[sessionurl]&do=green">Green</option>

find:

Code:
<td class="thead" align="center">$bracket13<b>Induction</b>$bracket14</td>

add below it:


Code:
<td class="thead" align="center">$bracket133<b>Color</b>$bracket143</td>

find:

Code:
<td class="tfoot" colspan="10">

replace with:

Code:
<td class="tfoot" colspan="11">

In the timeslipbit template:

Find:

Code:
<td class="alt2">$induction</td>

and below it add:

Code:
<td class="alt1">$color</td>

************PRODUCT EDITS************


Go to Plugin manager and scroll down to the Timeslips Database section.

Edit "Update timeslips data"

Find this line:

Code:
WHERE profilefieldid IN (50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65) AND editable IN (1,2)

Replace with this (replace XX with your new custom field number):

Code:
WHERE profilefieldid IN (50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,XX) AND editable IN (1,2)

Edit "vehicledetails"

Find this line:

Code:
WHERE profilefieldid IN (50,51,52,53,54,55,56,58,59,60,61,62,63,64,65) AND form = 0

Replace with this (replace XX with your new custom field number):

Code:
WHERE profilefieldid IN (50,51,52,53,54,55,56,58,59,60,61,62,63,64,65,XX) AND form = 0
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01326 seconds
  • Memory Usage 1,832KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (26)bbcode_code
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)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 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.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_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • 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
  • showpost_complete