Adding a New Field
By Paul
By Paul
Suppose you want article submitters to be able to specify a version number of what they're submitting. You can make this possible by adding a new field through the 'add fields' page in your admin panel. For this purpose you would choose 'article field' and choose a suitable name such as 'version'. Note that names are mysql field names and as a result of this they cannot have spaces or any other strange characters -- keep the name as simple as possible.
After you've chosen a type and name, you have options of what method you wish to use to let submitters supply the data. The simplest method is a regular input box, and for a version number this is likely what we would want. If the content will be a large amount of text (perhaps an article), you will want to choose the 'text area' option. If you wish to display options to let the submitter check a box for each one that applies to their article, use checkboxes. If you want to let them choose a single option from a dropdown menu (like the category selector in the top right of your screen now), then choose 'dropdown selector'. If you want a combo box that allows multiple selections (like your 'related categories' options on the edit category page), choose 'multiselect combo box'. To list several options in the same style as checkboxes but only allow the submitter to choose exactly one option (no more, no less), choose 'radio button'. Finally, if this field is not something that you want to be selectable or editable by anyone (even yourself), you may wish to make it invisible.
Next you can choose the text that will be shown as the description of the field. For example, for our version field we might write "Version Number" so that on the suggest link page "Version Number:" will appear in the left column.
Now you can select if non-administrators will be able to control the field. If you check the first box, it will appear to everyone as an option on the suggest link page. If you check the second box, it will appear on the edit article page for all link owners to edit (presuming you've set usergroup permissions to let them edit their links).
Finally, if you choose an option which involves multiple choices you can write out the options separated by commas.
Please note before pressing 'Add Field' that your templates must be chmoded to be writeable for all of this custom information you've just supplied to be properly inserted into your templates. If your templates are not chmoded, you will have to manually include the html for using the field. It's stongly suggested that you properly chmod the templates so that the proper code can be inserted into them for you automatically, as this will save you a lot of time and prevent accidental mistakes.
Once you're ready and have double checked everything, press 'Add Field' to create your field.
To use the data from your field, you will need to insert its template variable into your templates. The template variable will be in the form {TYPEFIELD}. For our version number example, we named the field version and it's a article field so the template variable is {ARTICLEVERSION}.
You can make refinements to your new field's displayed appearance by editing the templates -- specifically the editing and submission templates, plus whereever you want to display the data.
If you're dealing with a checkbox or single selector and want to test if a value is selected, you can use {ARTICLECHECKED[fieldname]} (or {CAT, {MEMBER etc) in your template conditional. If dealing with a multi-value checkbox or selector, you can use {ARTICLECHECKED[fieldname <,> value]} to test for each value.
After you've chosen a type and name, you have options of what method you wish to use to let submitters supply the data. The simplest method is a regular input box, and for a version number this is likely what we would want. If the content will be a large amount of text (perhaps an article), you will want to choose the 'text area' option. If you wish to display options to let the submitter check a box for each one that applies to their article, use checkboxes. If you want to let them choose a single option from a dropdown menu (like the category selector in the top right of your screen now), then choose 'dropdown selector'. If you want a combo box that allows multiple selections (like your 'related categories' options on the edit category page), choose 'multiselect combo box'. To list several options in the same style as checkboxes but only allow the submitter to choose exactly one option (no more, no less), choose 'radio button'. Finally, if this field is not something that you want to be selectable or editable by anyone (even yourself), you may wish to make it invisible.
Next you can choose the text that will be shown as the description of the field. For example, for our version field we might write "Version Number" so that on the suggest link page "Version Number:" will appear in the left column.
Now you can select if non-administrators will be able to control the field. If you check the first box, it will appear to everyone as an option on the suggest link page. If you check the second box, it will appear on the edit article page for all link owners to edit (presuming you've set usergroup permissions to let them edit their links).
Finally, if you choose an option which involves multiple choices you can write out the options separated by commas.
Please note before pressing 'Add Field' that your templates must be chmoded to be writeable for all of this custom information you've just supplied to be properly inserted into your templates. If your templates are not chmoded, you will have to manually include the html for using the field. It's stongly suggested that you properly chmod the templates so that the proper code can be inserted into them for you automatically, as this will save you a lot of time and prevent accidental mistakes.
Once you're ready and have double checked everything, press 'Add Field' to create your field.
To use the data from your field, you will need to insert its template variable into your templates. The template variable will be in the form {TYPEFIELD}. For our version number example, we named the field version and it's a article field so the template variable is {ARTICLEVERSION}.
You can make refinements to your new field's displayed appearance by editing the templates -- specifically the editing and submission templates, plus whereever you want to display the data.
If you're dealing with a checkbox or single selector and want to test if a value is selected, you can use {ARTICLECHECKED[fieldname]} (or {CAT, {MEMBER etc) in your template conditional. If dealing with a multi-value checkbox or selector, you can use {ARTICLECHECKED[fieldname <,> value]} to test for each value.
Rating:




2.67/5 based on 6 votes. The median rating is 2.
Rate this article:
Submitted: 11/11/03 (Edited 12/06/06)
Description: Tracking new data.
Views:
3184 views. Averaging 2 per day.
In the most recent 30 day period, there've been 0 views.

Print
E-Mail