Main
Index
Search
Posts
Who's
Online
Log
In

Home: Products: CMS Builder: Plugins & Add-ons:
Download Mail - convert _incoming_mailRecords fields within php header

 

 


zick
User

Jul 8, 2011, 11:28 PM

Post #1 of 5 (3442 views)
Shortcut
Download Mail - convert _incoming_mailRecords fields within php header Can't Post

I'd like to figure out a way to convert the fields of the _incoming_mailRecords in load records to sync up with some other records I'm using a page that I'm pulling multiple records into with an array. Is it possible to achieve the following and does any one have any suggestions how to do this?




Code
<?php header('Content-type: text/html; charset=utf-8'); ?> 
<?php
/* STEP 1: LOAD RECORDS - Copy this PHP code block near the TOP of your page */

// load viewer library
$libraryPath = 'abc/abc/viewer_functions.php';
$dirsToCheck = array('/var/www/vhosts/abc.com/httpdocs/','','../','../../','../../../');
foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }

// load records
list($_incoming_mailRecords, $_incoming_mailMetaData) = getRecords(array(
'tableName' => '_incoming_mail',
));
Is it possible to
convert subject to title
convert text and html to summary
convert attachments to media
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<style type="text/css">
body { font-family: arial; }
.instructions { border: 3px solid #000; background-color: #EEE; padding: 10px; text-align: left; margin: 25px}
</style>
</head>
<body>

<!-- INSTRUCTIONS -->
<div class="instructions">
<b>Sample List Viewer - Instructions:</b>
<ol>
<?php /*><li style="color: red; font-weight: bold">Rename this file to have a .php extension!</li><x */ ?>
<li><b>Remove any fields you don't want displayed.</b> (Most list pages only have title and link fields.)</li>
<li>Rearrange remaining fields to suit your needs.</li>
<li>Copy and paste code into previously designed page (or add design to this page).</li>
</ol>
</div>
<!-- /INSTRUCTIONS -->

<!-- STEP2: Display Records (Paste this where you want your records to be listed) -->
<h1>Incoming Mail - List Page Viewer</h1>
<?php foreach ($_incoming_mailRecords as $record): ?> so _incoming_mailRecords look like this in red?
Subject: <?php echo $record['subject'] ?><br/> becomes <?php echo $record['title'] ?>
Message Text: <?php echo $record['text'] ?><br/> becomes <?php echo $record['summary'] ?>
Message HTML: <?php echo $record['html'] ?><br/> becomes <?php echo $record['summary'] ?>
_link : <a href="<?php echo $record['_link'] ?>"><?php echo $record['_link'] ?></a><br/>


<!-- STEP 2a: Display Uploads for field 'attachments' (Paste this anywhere inside STEP2 to display uploads) -->
<!-- Upload Fields: num, createdTime, tableName, fieldName, recordNum, preSaveTempId, filePath, filename, extension, thumbFilePath, isImage, hasThumbnail, urlPath, width, height, thumbUrlPath, thumbWidth, thumbHeight, info1, info2, info3, info4, info5 -->
<?php foreach ($record['attachments'] as $upload): ?> becomes <?php foreach ($record['media'] as $upload): ?>
<?php if ($upload['hasThumbnail']): ?>
<img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" /><br/>

<?php elseif ($upload['isImage']): ?>
<img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="" /><br/>

<?php else: ?>
<a href="<?php echo $upload['urlPath'] ?>">Download <?php echo $upload['filename'] ?></a><br/>

<?php endif ?>
<?php endforeach ?>
<!-- STEP2a: /Display Uploads -->


<hr/>
<?php endforeach ?>

<?php if (!$_incoming_mailRecords): ?>
No records were found!<br/><br/>
<?php endif ?>
<!-- /STEP2: Display Records -->

</body>
</html>



robin
User / Moderator


Jul 11, 2011, 9:08 AM

Post #2 of 5 (3352 views)
Shortcut
Re: [zick] Download Mail - convert _incoming_mailRecords fields within php header [In reply to] Can't Post

Hey zick,

So you just need the variable names changed? Something like this might be helpful:


Code
  // load records  
list($_incoming_mailRecords, $_incoming_mailMetaData) = getRecords(array(
'tableName' => '_incoming_mail',
));

foreach($_incoming_mailRecords as &$record) {
$record['title'] = $record['subject'];
$record['summary'] = $record['text'];
$record['media'] = $record['attachments'];
}
unset($record);


Hope that helps,
Robin


zick
User

Jul 11, 2011, 10:26 AM

Post #3 of 5 (3350 views)
Shortcut
Re: [robin] Download Mail - convert _incoming_mailRecords fields within php header [In reply to] Can't Post


In Reply To
Hey zick,

So you just need the variable names changed? Something like this might be helpful:


Code
  // load records  
list($_incoming_mailRecords, $_incoming_mailMetaData) = getRecords(array(
'tableName' => '_incoming_mail',
));

foreach($_incoming_mailRecords as &$record) {
$record['title'] = $record['subject'];
$record['summary'] = $record['text'];
$record['media'] = $record['attachments'];
}
unset($record);


Hope that helps,
Robin



Thanks Robin, this almost has me there... can you tell me how to combine the 'text' and 'html' fields from _incoming_mail into one, so it doesn't matter if some sends text or html in the message... they both become 'summary'.

Code
    // load records 
list($_incoming_mailRecords, $_incoming_mailMetaData) = getRecords(array(
'tableName' => '_incoming_mail',
'perPage' => '5',
//'orderBy' => 'createdDate DESC',
));

foreach($_incoming_mailRecords as &$record) {
$record['title'] = $record['subject'];
$record['summary'] = $record['text'];
$record['summary'] = $record['html'];
$record['media'] = $record['attachments'];
}
unset($record);

$mediaMerge = array();
$mediaMerge = array_merge($galleryRecords, $newsRecords, $_incoming_mailRecords);


What I'm doing is merging three records into a single page using an array $mediaMerge = array();

Thanks,
Zick


robin
User / Moderator


Jul 12, 2011, 9:22 AM

Post #4 of 5 (3246 views)
Shortcut
Re: [zick] Download Mail - convert _incoming_mailRecords fields within php header [In reply to] Can't Post

Hey Zick,

To do a straight combine this will work:

Code
$record['summary'] = $record['text'] . $record['html'];


If you just want one or the other depending on which one is filled, this will help out:

Code
$record['summary'] = coalesce($record['text'], $record['html']);

That is giving text the priority if they are both filled, swap the variables if you want html to have priority.


Hope that helps,
Robin


zick
User

Jul 12, 2011, 10:07 AM

Post #5 of 5 (3241 views)
Shortcut
Re: [robin] Download Mail - convert _incoming_mailRecords fields within php header [In reply to] Can't Post

Thanks for the two solutions Robin!!!!
I've got them plugged into my site.
I really appreciate the help.
Zick