Webmastersite.net
Register Log In

checkbox value separator
how to change a comma to something else?

Comments on checkbox value separator

david
Forum Regular

Usergroup: Customer
Joined: Jun 22, 2005

Total Topics: 91
Total Comments: 305
david
Posted Nov 23, 2006 - 12:22 PM:

Hello Paul,

Quick question. I have a text type database field. I have several checkboxes to enter values into it. I want to display the values on a page. By default, {LINKWHATEVERTHISFIELDIS} would display something like:

value1, value2, value3, etc

It puts a comma between the values. How can I change this to something else, like a line-break or something.

Thank You
David
Paul
developer

Usergroup: Administrator
Joined: Dec 20, 2001
Location: Diamond Springs, California

Total Topics: 61
Total Comments: 7868
Paul
Posted Nov 23, 2006 - 4:38 PM:

If you know all the possible values you could do
<IF {LINKCHECKED[field <,> value1]}> value1<br></IF>
<IF {LINKCHECKED[field <,> value2]}> value2<br></IF>

but if you don't you can use some PHP:
<?php echo str_replace(',' '<br>', '{LINKWHATEVERTHISFIELDIS}'); ?>
webflair
Forum Regular

Usergroup: Customer
Joined: Nov 27, 2006

Total Topics: 187
Total Comments: 465
Posted Apr 26, 2007 - 9:54 AM:

<?php echo str_replace(',' '<br>', '{LINKWHATEVERTHISFIELDIS}'); ?>

So where would you put this php?
webflair
Forum Regular

Usergroup: Customer
Joined: Nov 27, 2006

Total Topics: 187
Total Comments: 465
Posted Apr 26, 2007 - 11:37 AM:

<IF {LINKCHECKED[field <,> value1]}> value1<br></IF>
<IF {LINKCHECKED[field <,> value2]}> value2<br></IF>

I don't really understand what you would replace the field and value with, well actually, the value isn't a problem, but what do I replace the field with and how would it be written? In { } ?

I really need to get the values to display as bullet points.

my link field is {LINKSERVICESLIST}

And my values are...

1 hour lessons
2 hour lessons


So how would it be put into bullet points instead of the commas it outputs as standard?

Thanks in advance.
Paul
developer

Usergroup: Administrator
Joined: Dec 20, 2001
Location: Diamond Springs, California

Total Topics: 61
Total Comments: 7868
Paul
Posted Apr 26, 2007 - 2:54 PM:

If your template variable is {LINKSERVICESLIST} that must mean you named your field serviceslist, so
<IF {LINKCHECKED[serviceslist <,> 1 hour lessons]}>this one has one hour lessons</IF>


As for placing the PHP, you put it wherever you want it shown in the template.

With bullets instead of line breaks:
<?php echo str_replace(',' '<li>', '{LINKSERVICESLIST}'); ?>
webflair
Forum Regular

Usergroup: Customer
Joined: Nov 27, 2006

Total Topics: 187
Total Comments: 465
Posted Apr 27, 2007 - 9:20 AM:

If I put the PHP version in a template, the page shows as a blank white page.
Paul
developer

Usergroup: Administrator
Joined: Dec 20, 2001
Location: Diamond Springs, California

Total Topics: 61
Total Comments: 7868
Paul
Posted Apr 28, 2007 - 4:19 PM:

Do you have error suppression on? Get the debug output. We're talking about 4.0.26 here I presume?
webflair
Forum Regular

Usergroup: Customer
Joined: Nov 27, 2006

Total Topics: 187
Total Comments: 465
Posted Apr 28, 2007 - 4:29 PM:

Sorry paul, I should have posted, i sorted this problem. Thanks
Search thread for
Download thread as
  • 0/5
  • 1
  • 2
  • 3
  • 4
  • 5



This thread is closed, so you cannot post a reply.