MyBB Hacks

Full Version: How to style each line of a textarea list?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
e.g., user inputs

"Item 1
Item 2"

output is

Code:
<span class="item">Item 1</span> <span class="item">Item 2</span>

Option 1:
Allow multiple values for the field, set delimiter to be &nbsp;.
If all are the same format, use in Display Item Format

Code:
<span class="item">{VALUE}</span>

otherwise use the Format Map List to assign specific mappings.

Option 2:
If you wish to keep it to be a singular value, use the following as the Display Format

Code:
<span class="item">
<?=str_replace("\n", '</span><span class="item">',
 str_replace("\n\n", "\n",
   str_replace("\r",'',trim({VALUE}))
 )
)?>
</span>

May be an issue if the user decides to put multiple blank lines.
(this also assumes that the Display Parsing is set to Plaintext (without newlines))

Reference URL's