Introduction
The smart number field type addon is based on the number. Smart number field type addons have both functionalities that work in the backend and frontend as well. It is easy to use and compatible with Channel entry, Grid, Fluid, and Relationship Field.
The Smart Number Field is an ExpressionEngine field type addon that allows users to get the numbers. It gets the text input field with only numbers. No characters are allowed. This field type addon is also compatible with third-party addons.
Compatibility
EE Compatible Version: EE4 & EE5.
Some of the features of the Smart Number Field type are given below:
- Easy to setup,install and use.
- Compatible with the Grid field.
- Compatible with the Fluid and Relationship field.
- Compatible with Channel Forms.
Installation
Follow the below steps to install the Smart Number Field type addon
EE4 & EE5:
- Download and Extract ZIP file of the addon of “Smart Number Field”.
- Copy “SmartNumberField > system > user > addons > smart_number_field” folder to “Your Site > system > user > addons” Folder.
- Login to backend panel with Super admin credentials.
- Go to “Developer > Add-Ons” and Install Smart number field addon.
- Click ‘install’ on “Smart Number Field”
Create/Edit Field
Follow below steps to create new Smart Number Field:
- Go to field manager and click on “New Field”
- Select Smart Number Field type in the input type box. You will find field options for this field type at the bottom.
There is few field options in the backend of the smart number field:
- Float Value
- Number Format
- Default Value
- Placeholder Text
- Prepend
- Append
- Minimum Value
- Maximum Value
- Step Size
Float Value
First,field options consist of float values that are in the form of switch cases (yes/no).
This option shows the value of any number/price in the float format in the frontend.
The maximum and minimum value will show in the float format in the back-end field option when enabled.
Number Format
This field option is also in the form of a switch case (yes/no).
If you enable the switch, it shows the number format’s value with a comma(,) as the thousand separators in the frontend.
Default Value
This field option is to work to get the default value.
If you put the value in the default text input type and there will be no value of data in the channel entries.
Placeholder Text
This field option is to work in the back-end only.
If you place any message in a placeholder in the field options of the text input.
These messages will appear in the channel entries input field type as a placeholder.
Prepend
This input type field option works to take any symbol to show the price/number’s presiding.
It will then show the price in the frontend with its symbol added in the back-end prepend field options.
Append
The append field option works to show value in the post side with its price/number value. This value will show in the frontend.
Minimum Value
The minimum value field option is to work in the back-end only. Suppose we put the minimum value in the input field. It will only take the values according to the minimum value shown in the input entries. If the minimum limit extends, it will show validation errors. The minimum value takes numbers only. No characters are allowed. It also allows negative value.
Maximum Value
The maximum value field option is to work in the back-end only. Suppose you put the maximum value in the input field options. It will only take the value according to the maximum value from the back-end. If the maximum limit extends, it will show validation errors. Maximum value takes number only, no characters are allowed. It also allows negative value.
Step Size
Step size field option works in the back-end only. This field option works to show according to the value given in step size. It takes value in channel entries as per the given step size in it.
If the minimum value and step size both value in field options, it will take the value in channel entries according to step size and minimum value.
Fieldtype
Normal field example
{exp:channel:entries} {title} {url_title} {smart_number} {/exp:channel:entries}
Example with GRID
{exp:channel:entries} {number_grid} {number_grid:snf_normal_field wrap_tag="h3"} {number_grid:snf_normal_field prepend_tag="h6"} {number_grid:snf_normal_field append_tag="h2"} {number_grid:snf_normal_field append_first="y"} {/number_grid} {/exp:channel:entries}
Example with Fluid Field
{exp:channel:entries} {fluid_field} {fluid_field:snf_normal_field} {content wrap_tag="h3"} {content prepend_tag="h6"} {content append_tag="h2"} {content append_first="y"} {/fluid_field:snf_normal_field} {/fluid_field} {/exp:channel:entries}
Front end Tags
Smart number field front-end tags are just like to use channel entries tag. We have introduced new tags in field tags that will allow us to filter the output in the frontend.
wrap_tag
wrap_tag is used to wrap the data or content in the particular HTML tag(h1,h2…h6,span,p,b and so on) with the smart number field.
Example:
{snf_number wrap_tag="h3"}
prepend_tag
prepend_tag is used to get the prepend value data in the particular HTML tag(h1,h2…h6,span,p,b and so on) format with the smart number field.
Example:
{snf_number prepend_tag="h6"}
append_tag
append_tag is used to get the append value data in the particular HTML tag(h1,h2…h6,span,p,b and so on) format with the smart number field.
Example:
{snf_number append_tag="h2"}
append_first
append_first tag is used to get the append tag value in the preside of the data with the condition (”Yes” or “y”) . If user don’t want this condition they can usually put no condition (”No” or “n”)
Example:
{snf_number append_first="y"}