This topic is locked

commas to new line in multiline fields

1/22/2010 4:30:42 PM
PHPRunner General questions
R
rmac author

I'm trying to get multiple values to display as individual lines vs. comma separated values (ie)
first

second

instead of
If I concatenate a \n in the sql query I get this
[font="Lucida Console"]first

,second

close, but not quite. I found this topic on using a custom "view as" setting which DaleM said worked for him, however I can't seem get PHPR to recognize str_replace. If I use any of the example snippets (strtoupper, strtolower, etc) they work and as soon as the command is typed it turns blue. str_replace does not and has no effect on the output. I've tried it in both 5.1 and the latest 5.2 beta with the same results.
Any ideas, or a different way to accomplish this? Thanks.

D
Dale 1/22/2010

Sure, on the visual editor, double click the multiline field and select properties.

Select VIEW AS, and then select CUSTOM and enter the code below.
if($value)

$value = str_replace(",","<br />",$value);
Rebuild and the field should display in the list page with each selected value on its own line.
Should work. I found an issue when I Printed the list page using the print buttons.

When printing it would not split the values into new lines.
Maybe this is not an issue any more.

I had to modifiy the source file print.php to make it work for the printing too.

R
rmac author 1/24/2010

Dale;
Thanks for the reply. Yeah, that is what I'm doing. I spent a little more time and think I have a better idea of the problem, but still not a fix. I can get str_replace to swap a <br /> for any character I append to the field through CONCAT, but NOT the comma that gets inserted by multiline. For example:
[indent]FIELD= pn

set to multiline and use your Custom Vies As code $value = str_replace("","<br />",$value); I get this:




FIELD= concat(pn,":")

set to multiline and use your Custom Vies As code $value = str_replace("[color="#000080"]:","<br />",$value); I get this:
[font="Lucida Console"]part1

,part2


[/indent]

This works no matter what I CONCAT with the output, including another comma. It looks like the program is inserting the multiline comma after the Custom View As is run. I wonder why it works differently on your project. My field values are coming from a lookup table, but I assume your's probably are too. Offhand, I can' think of any other significant variations available. Maybe someone else will have some insight.
Ray

J
Jane 1/26/2010

It's difficult to tell you what's happening without seeing actual files.
Please publish your project on Demo Account and open a ticket at http://support.xlinesoft.com sending a URL to your pages along with instructions on reproducing this error.