View newsletter online
2 posts by 2 authors in: Forums > CMS Builder: Plugins & Add-ons
Last Post: June 17, 2013 (RSS)
By Toledoh - June 17, 2013
Hi Guys,
Is there the ability to add a link in a newsletter to an online version of that specific email, but not a link to an "archive" of all records?
Tim (toledoh.com.au)
By gregThomas - June 17, 2013
Hi Tim,
There is no preset link you can use, but creating the link manually should be fairly straight forward.
You can get the record num for a specific news letter using the #message_num# placeholder, you could use this to create your own newsletter detail page link like this:
http://#hostname#/archive.php?view-newsletter-#message_num#
Then you would create archive.php to pull the record from the _nlb_messages section using a getRecords function, the basic code would need to look something like this:
<?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 = 'cmsAdmin/lib/viewer_functions.php';
$dirsToCheck = array('C:/wamp/www/','','../','../../','../../../');
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 record from 'accounts'
list($newsletter, $accountsMetaData) = getRecords(array(
'tableName' => '_nlb_messages',
'where' => whereRecordNumberInUrl(0)."AND send IN ('all','archive')",
'loadUploads' => true,
'allowSearch' => false,
'limit' => '1',
));
$newsletter = @$newsletter[0]; // get first record
if (!$newsletter) { dieWith404("Record not found!"); } // show error message if no record found
//Replace the placeholders in the current newsletter
$newsletter = nlb_viewers_replacePlaceholders($newsletter);
?>
<h1><?php echo$newsletter['subject']; ?></h1>
<?php echo $newsletter['html']; ?>
So this code retrieves the record number from the URL, then retrieves the related detail record from _nbl_messages section. Then displays the subject and content. The nlb_viewers_replacePlaceholders function will replace the placeholders in the message with the correct values.
Let me know if you have any questions.
Thanks!
Greg
PHP Programmer - interactivetools.com