Echo variable inside of textbox

14 posts by 4 authors in: Forums > CMS Builder
Last Post: November 18, 2011   (RSS)

By Jason - November 17, 2011 - edited: November 18, 2011

Hi Jerry,

I took a look at your code. It seems that var6, 7, and 8 are all dependent on each other. If there is no special location name, there probably won't be an address.

In that case, we can replace 6, 7, and 8 with a single placeholder and combine those 2 fields into a single string.

So the text box would look like this:

You're all signed up for <b>"*var1*"</b>
on <b>*var3*, from *var4*</b>
*var6*

We suggest that you arrive at least 15 minutes early so that you can get to know some of the other attendees.

As a reminder, here's a copy of the description of this event.

"*var5*"

We look forward to seeing you there.


and the PHP would look like this:

<?php

$event_start_date = date("l, M jS, Y", strtotime($learning_centerRecord['event_start_date'])) ;

$special_location = "";
if (@$learning_centerRecord['special_event_location_name']) {
$special_location = "<b>Special Location: ".$learning_centerRecord['special_event_location_name']."</b>\n".$learning_centerRecord['special_event_location_address'];
}

$placeHolders = array("*var1*", "*var2*", "*var3*", "*var4*", "*var5*", "*var6*", "*var7*", "*var8*" );
$replaceWith = array($learning_centerRecord['event_title'], $learning_centerRecord['event_fee'],
$event_start_date, $learning_centerRecord['event_times'],
$learning_centerRecord['event_description'], $special_location);

echo str_replace($placeHolders, $replaceWith, $common_informationRecord['learning_center_thank_you_1']);
?>


Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Echo variable inside of textbox

By gkornbluth - November 17, 2011 - edited: November 18, 2011

See, that's the difference between us tinkerers and someone who really knows how to write elegant code.

Thank you Jason.

The solution you suggested worked perfectly.

It may not be possible, but do you have any ideas for how to eliminate the blank line that's left in the viewer when there's no information in the $special locations variable?

Again, thanks...

Jerry Kornbluth
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

Re: [Jason] Echo variable inside of textbox

Great idea.

And I've learned a bit about arrays as well.

We are lucky to have you around.

Jerry Kornbluth
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php