Coding syntax question

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

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

By gkornbluth - August 7, 2009

Thanks Dave,

I tried the error reporting code, but still get only a blank screen and source.

Here's the generic layout of the code I'm using:

<?PHP echo $emailcode->emailgetencode($record['e_mail'],'VISIBLE TEXT','Your mail subject','YOURCLASS','xhtml'); ?>

With this code above it in the body. <?PHP
require 'emailcode.class.php';
$emailcode = new ClassEmailcode();?>
I've attached the emailcode.class.php file just to be complete.
_____________

Here's the code that works to replace the VISIBLE TXT with an image
<?php echo $emailcode->emailgetencode($common_informationRecord['contact_e_mail'],'<img border="0" src="images/email.png">','','special','xhtml');
?>

Here's the actual code that I'm trying to implement to replace the VISIBLE TXT with an image from the database.

<?php echo $emailcode->emailgetencode($common_informationRecord['contact_e_mail'],'<img src="<?php foreach ($common_informationRecord['e-mail_logo'] as $upload): ?><?php echo $upload['thumbUrlPath'] ?>" border="0" />
<?php endforeach ?>','','special','xhtml');
?>


I'm pretty sure that it has something to do with the way trying to put one php call inside another, but I don't know how to fix it.

Thanks,

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
Attachments:

emailcode-class.php 41K

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