In this example I will add a drop select box to a manufacturer in X-Cart. The select box will have a Yes/No option and will default to Yes. The field will be used in the front end to show the manufacturers in a drop down in the main navigation.

Add new field to xcart_manufacturers

We will need to add a new field to the xcart_manufacturers table called show_in_menu which is the datatype ENUM like so. I use HeidiSQL for ease.

Edit admin screen to edit the Manufacturers

You then need to find and edit /httpdocs/skin/common_files/modules/Manufacturers/manufacturers.tpl

Find

<tr>
  <td class="FormButton">{$lng.lbl_availability}:</td>
  <td>&nbsp;</td>
  <td><input type="checkbox" name="avail" value="Y"{if $manufacturer.avail eq 'Y' or $manufacturer.manufacturerid eq ''} checked="checked"{/if} /></td>
</tr>

Add After

<tr>
  <td class="FormButton">{$lng.lbl_show_in_menu}:</td>
  <td>&nbsp;</td>
  <td><input type="checkbox" name="show_in_menu" value="Y"{if $manufacturer.show_in_menu eq 'Y'} checked="checked"{/if} /></td>
</tr>

You will need to add the language variable in xcart lbl_show_in_menu and set this to the text ‘Show in Menu’

Test the page

Now when you goto edit a manufacturer you will see ‘Show in Menu’ option pre ticked as we set ‘Y’ as the default value in the database table.

But if you change this value will not change after you click apply changes as we still need to update the server side code which handle the update.

Edit the PHP server side script

Because we are updating an administrative field which is only accessible to main admins the update is slightly different to just a regular field. I have documented both here.

Regular field

find this

update like this

You will see this twice in the script and so will need to update both.

Administrative Field

find

update like this

You will see this twice in the script and so will need to update both.

You will need to find the following and add the line below to it