Coding syntax question

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

By gkornbluth - August 6, 2009

Hi all,

I’ve been using an e-mail address encryption program to keep bots from harvesting e-mail addresses from my pages.

I’m having trouble with the code syntax that I need to embed a graphic in the link instead of text.

Here’s the code in question:

<?php echo $emailcode->emailgetencode($common_informationRecord['contact_e_mail'],'click here to e-mail us','','special','xhtml');
?>


Which pulls the e-mail address from a “contact_email” field.

I can embed a single graphic with code like this to replace the “click here to e-mail us” text.

<?php echo $emailcode->emailgetencode($common_informationRecord['contact_e_mail'],'<img border="0" src="images/email.png">','','special','xhtml');
?>


When I try to pull the e-mail address from the “contact_e-mail field” and the graphic from the upload field “email_graphic”, I can’t seem to get the syntax right and I’m greeted by that dreaded blank white screen.

Any direction would be appreciated.

Best,

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] Coding syntax question

By Dave - August 6, 2009

Hi Jerry,

Try the code in this post to enable error reporting. That should give you a better clue what's going on.

http://www.interactivetools.com/forum/gforum.cgi?post=66917#66917

Let me know if that helps or provides any more details.
Dave Edis - Senior Developer
interactivetools.com

Re: [gkornbluth] Coding syntax question

By Chris - August 7, 2009

Hi gkornbluth,

Yes, you cannot put PHP tags inside of a string inside of PHP. Here's an alternate approach:

The following code will find the first image in the e-mail_logo field and generate an <img> tag for it, or use the string "click here to e-mail us" if no image is available, then pass that off to $emailcode->emailgetencode().

<?php
$visibleText = "click here to e-mail us";
foreach ($common_informationRecord['e-mail_logo'] as $upload):
if ($upload['isImage']):
$visibleText = "<img src=".$upload['thumbUrlPath']." width=".$upload['width']." height=".$upload['height']." alt='' />";
break;
endif;
endforeach;
echo $emailcode->emailgetencode($common_informationRecord['contact_e_mail'],$visibleText,'','special','xhtml');
?>


Please let us know if this solves your problem.
All the best,
Chris

Re: [chris] Coding syntax question

By gkornbluth - August 7, 2009 - edited: August 12, 2009

Thanks Chrs,

It certainly is easier when you understand the finer points...

Your solution worked like a charm.

One question:

What do the periods indicate before and after things like: width=".$upload['width']."

Thanks again,

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: [gkornbluth] Coding syntax question

By Chris - August 7, 2009

Hi gkornbluth,

The period is the [url http://www.php.net/manual/en/language.operators.string.php]concatenation operator in PHP[/url], which joins two string together.

Glad this worked for you!
All the best,
Chris