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/

By Jason - November 18, 2011

Hi Jerry,

Good catch, I removed the extra ; in the previous post.

One thing you could do is remove the blank space between *var6* and the next line. Then, in the $special string, you can add an extra "\n" to put a blank line after *var6* if a value is there.

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

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