Strip spaces out

8 posts by 3 authors in: Forums > CMS Builder
Last Post: April 24, 2009   (RSS)

Hi guys,

I'm using the CMS to populate a line of javascript that would work fine except the code is presenting like this:

<script type="text/javascript">new ToolTip('tooltip-10', 'Learn more about:<br/>
- Expanding businesses into Australia<br/>
- Import and Export<br/>
- International Franchising<br/>
- Migration Law<br/>
- Law Firm Network', { mode: 'cursor', display: 'inline', width: 240, style: 'default', sticky: 0 });</script>

When it needs to present on one line, like this:

<script type="text/javascript">new ToolTip('tooltip-10', 'Learn more about:<br/>- Expanding businesses into Australia<br/>- Import and Export<br/>- International Franchising<br/>- Migration Law<br/>- Law Firm Network', { mode: 'cursor', display: 'inline', width: 240, style: 'default', sticky: 0 });</script>

Can you please let me know how to strip the spaces out so it all appears on one line? This is the code I have currently:

<?php foreach ($servicesRecords as $record): ?>
<div id="tooltip-<?php echo $record['num'] ?>" class="sidenav_heading"><a href="<?php echo $record['_link'] ?>"><?php echo $record['title'] ?></a></div>
<p>
<script type="text/javascript">new ToolTip('tooltip-<?php echo $record['num'] ?>', '<?php echo $record['navigation_bubble'] ?>', { mode: 'cursor', display: 'inline', width: 240, style: 'default', sticky: 0 });</script>
</p>
<?php endforeach; ?>

Thanks.

Re: [benedict] Strip spaces out

By Dave - January 26, 2009

Hi benedict,

Try adding this line:

<?php foreach ($servicesRecords as $record): ?>
<?php $record['navigation_bubble'] = strtr($record['navigation_bubble'], "\n", ""); ?>
...


Let me know if that works for you.
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Strip spaces out

Hi Dave,

Alas, no good. Still does the exact same thing.

Re: [benedict] Strip spaces out

By Dave - January 27, 2009

I'm not sure which spacing characters are present. Try this:

<?php foreach ($servicesRecords as $record): ?>
<?php $record['navigation_bubble'] = preg_replace("/\s+/", " ", $record['navigation_bubble']); ?>
...


If that doesn't work feel free to email me CMS and FTP login details to dave@interactivetools.com and I can take a look for you. (Email, don't post login details to the forum).

Hope that helps!
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Strip spaces out

That's done the trick. Thanks Dave.

Re: [Dave] Strip spaces out

Hi Dave,

I'm wondering if this is the same type of code that I'd use to strip those characters from a text field entry that are not acceptable in a PayPal buy link (like quotation Marks, Asterisks, Question Marks, etc.)?

And if that's so, could you give me an example of the correct syntax to use with those 3 and I'll be able to expand it from there.

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: [Dave] Strip spaces out

By gkornbluth - April 24, 2009 - edited: April 24, 2009

Thanks Dave,

I'm sure it will.

I'll give it a look this weekend
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