Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 How to style each line of a textarea list?
brad-t Offline
Member
***
Posts: 120
Joined: Apr 2011
Post: #1
How to style each line of a textarea list?
e.g., user inputs

"Item 1
Item 2"

output is

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

05-18-2012 07:08 AM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #2
RE: How to style each line of a textarea list?
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:
1
2
3
4
5
6
7
<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))


My Blog
(This post was last modified: 05-18-2012 09:34 AM by ZiNgA BuRgA.)
05-18-2012 09:32 AM
Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

 Standard Tools
Forum Jump: