How to use textbox to display 3rd-party code items?

7 posts by 3 authors in: Forums > CMS Builder
Last Post: August 5   (RSS)

Hello all,

Years ago I could simply set up a text box field and have the customer input a string of 3rd-party code (like paypal for example) and as soon as the record was saved the paypal buttons would appear on the live public page no problem - easy-peasy.  However, with more recent CMSB versions (I'm using ver 3.71), the public page literally shows the text of 3rd-party script code.

How can I make the textbox work and show functions or items for 3rd-party code?  In this particular case, the client is using paypal. They have different products with different prices so a copy-paste-3rd party code would be terrific.

Thank you kindly.

Hi Tim, 

Thanks for replying. Yeah, I get what you're saying and thought of that...and then I reviewed some sample code from the paypal generator (log into paypal, put all your parameters in, and they provide a small script, including with some security parameters so that price can't be changed, etc.) and realized "Dude, no clue here."  I am only speaking about this type of paypal button at this time.  Here's a sample of a code script that is for white buttons, choice of paypal, venmo, credit/debit, pay later, for $500, bullet style, and some customized naming/text:

"<script src="https://www.paypal.com/sdk/js?client-id=BAAjui822kRiVjHQ8qZogINx4vRK6tJv6vh42BltPxPcQTk3Q4yBCbZ2kdUrx_Q5rV3mNnelDEd6dVaVcI&components=hosted-buttons&enable-funding=venmo&currency=USD"></script><br>
<div id="paypal-container-8F4CVZMVS7L2C"></div><br>
<script><br>
paypal.HostedButtons({<br>
hostedButtonId: "8F4CVZMVS7L2C",<br>
}).render("#paypal-container-8F4CVZMVS7L2C")<br>
</script>"

That's it.  My client is not overly techy but can point-click-type so I was desiring the ability to copy-paste this into a field and have it show up on the site.  If I hardcode this on the page it works terrific. If I attempt to run it through a CMSB textbox field then the script shows up, literally, as text.  

Is there a simple solution?

Hi Codee,

When outputting your text box with the paypal code are you using a plain echo like:

<?php echo $record['paypal_code']; ?>

?

Thanks,
Robin

Robin
Programmer
interactivetools.com

Good morning,

I was using the code like that, and then tried it like this:

<?php echo htmlencode($galleryRecord['paypal_code']) ?>

Hey Codee - I think a plain:
<?php echo $galleryRecord['paypal_code']; ?>
...should work.  

Another thing to look for is to make sure "Disable auto-formatting" is checked in the text box settings.  The auto-formatting can cause trouble with code.  

Let me know if you're still having trouble and we'll figure it out.

Thanks,
Robin

Robin
Programmer
interactivetools.com

Hi Robin,

Thank you kindly. I tried that initially because that is how it used to work. So, I plugged that back in.  It didn't work, then I noticed that Paypal's button code included <br> tags...which was not included in their earlier versions of their script buttons.  THAT is what was making it not work.  So I edited out paypal's break tags and then input the code string into the text box. Saved. Now it works!  Thank you so much for following up with me on this.  I knew it had to be something simple.  Kudos to you!