Errant Spaces and "If" statments

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

By gkornbluth - March 28, 2009

I've been using if statements to test for optional information.

If the information is present then it's displayed on the web page along with a heading.

The problem is that if inadvertently there's a space or a return in an optional field, it's interpreted as content and the heading appears on the page.

Anyone know how I would test for spaces and returns with no other characters present and not show the headings?

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: [gkornbluth] Errant Spaces and "If" statments

By ross - March 30, 2009

Hi Jerry

What you'll want to do here is view the source where the extra spaces are showing up just to see what the output is. If it's a <br> or a <p> tag then you can try the if's on that like

if value is not equal to <br> or <p> then display the field.

Does that make sense? Give it a shot and let me know :)
-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/

Re: [ross] Errant Spaces and "If" statments

By gkornbluth - March 30, 2009

Thanks Ross,

I'll play with this and post the result.

Jerry
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] Errant Spaces and "If" statments

By gkornbluth - April 1, 2009

I think this will do the trick.

Thanks as always.

I'll post my result here.

Jerry
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] Errant Spaces and "If" statments

By gkornbluth - April 16, 2009

Good morning Dave,

Sorry that it took so long to respond.

The fix above works perfectly.

Just curious, You mentioned the option of automatically removing any left over leading and/or trailing spaces, before testing, how would I do that.

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: [gkornbluth] Errant Spaces and "If" statments

By ross - April 16, 2009

Hi Jerry

The remove leading and trailing space option would involve the trim() function. I am thinking if the solution Dave gave you already works though, that should be fine. Either option would have the same result and you've already set that one up.

You can read about the trim function the PHP site here:


http://ca.php.net/trim


Keep us up to date with how you are making out. Thanks!
-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/