Inserting HTML code into a text field

4 posts by 3 authors in: Forums > CMS Builder
Last Post: September 23, 2011   (RSS)

Hi,

I am trying to insert the following code into a text field inside CMSB:

Lots of surrounding text then I need to show the current date <?php echo date("d.m.y"); ?> then it's surrounded by loads more text.

However in the output the area is blank but the PHP code shows in the page source code.

I know we can use use PHP in the HTML part of a divider within CMSB but I am guessing what is happening in the text field is by design.

Is it possible to show simple PHP stuff like this in a text field/box etc?

I did find this post in my searching for a solution:
http://www.interactivetools.com/iforum/Products_C2/CMS_Builder_F35/gforum.cgi?post=87343;search_string=php%20security;t=search_engine#87343

but all I ever got was the following error regardless of where I placed the semi colons etc in a attempt to process it correctly after reading up on the eval function over at php.net:
Parse error: syntax error, unexpected T_STRING in /blah/blah/blah/blah/blah/blah/blah.php(479) : eval()'d code on line 1

All ideas / suggestion welcomed with thanks as always ;)

Paul

Re: [Pixels & Beats] Inserting HTML code into a text field

By Jason - September 22, 2011

Hi Paul,

You can use the CMS Builder Function getEvalOutput that takes in a string and executes any PHP that it finds inside.

So, for example, if you have a text field called "date" that had some PHP code that you wanted to display, you could use this:

<?php echo getEvalOutput($record['date']);?>

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] Inserting HTML code into a text field

Jason: Works like a dream!

Toledoh: Interesting approach. Time constraints mean I can't experiment with it, but will keep in mind for the future.

Thank you both for your excellent input as always :)

Paul