CB Database Lookup Field plugin Guide¶
Installation and Publishing¶
Download latest package from the project files area here.
Use the CB Plugin Management area to install this as a CB plugin.
Enable/publsh the plugin after you install it. The plugin name will appear as DB Lookup field in the CB Plugin Management summary page.
Field Creation and Configuration¶
Once the plugin is installed and published a new field type of "DB Lookup" will appear in the drop-down Type: parameter when creating a new CB field.
Once "DB Lookup" is selected as a field type, you will see extra DB Lookup related parameters in the right.
These parameters have default settings that will work with the sample testcodes table (see next chapter).
The screenshot below shows a DB Lookup field created that we have also placed on an Admin tab (only appears for superadmins).
The field is marked to appear during registration and also is configured as a Readonly field.
The extra DB Looukup specific parameters have been configured to work with the testcodes table (see next chapter).
Sample "testcodes" table¶
The testcodes table is a simple three column table that contains an 'id' column (just an auto-increment int value), a 'code' column (a char string) and a 'userid' column (initialized to 0 to mean that it is not used).
The structure of this table is illustrated in the following screenshot.
We have also populated the table with 4 codes: hello1, hello2, hello3 and hello4 as shown in the following screenshot.
Operation Overview¶
With the field published and the testcodes table configured as previously described, our registration form will show a 'Registration Access Code:' field which is required and must be populated with a value that is free (has 0 value for userid column).
If the value entered does not validate against the testcodes table, then our registration form will fail and a popup message will appear.
If the value entered validates then the registration form will complete and the entered value will be saved in the field and the testcodes table will be updated to place the userid of the registration forum user.