Welcome to Geeklog, Anonymous Friday, March 29 2024 @ 08:18 am EDT

Geeklog Forums

Daily digest in HTML format?


ChrisN

Anonymous
Hi,


How do I get my daily digest to send out the identical HTML to what appears on GL?


I have my daily digest email working, and after I set the $html = true param in COM_mail, the digest is going out in HTML format. Unfortunately, GeekLog is sending only the plain text of the stories in the email, not the HTML! Resulting in a very ugly email indeed, with everything on one line.


Please help! Banging your head


Thanks!

 Quote

ChrisN

Anonymous
I found the hack I did in the previous (v1.3) version of GeekLog to fix this issue, which was to remove strip_tags from this line:

/** old version */
$storytext = COM_undoSpecialChars( strip_tags( PLG_replaceTags( stripslashes( $S['introtext'] ))));

/** hacked version */
$storytext = COM_undoSpecialChars( PLG_replaceTags( stripslashes( $S['introtext'] )));

Anybody see any problem with this? I can only test this on the live server and so I'd like at least a thumbs up from somebody who knows before I do it.

In the previous version I also had to make this hack to enable the HTML email, but I can't find the equivalent in the v1.4 code. Anybody know where it is, or if it's still even necessary?

/** old version with rn that throws errors
* $mailfrom = "From: {$_CONF['site_name']} <{$_CONF['site_mail']}>rn"
* . "Return-Path: <{$_CONF['site_mail']}>rn"
* . "Content-Type: text/plain; charset={$charset}rn";
* . "X-Mailer: GeekLog " . VERSION;
*/

/** hacked version with HTML format*/
$mailfrom = "From: {$_CONF['site_name']} <{$_CONF['site_mail']}>n"
. "Return-Path: <{$_CONF['site_mail']}>n"
. "MIME-Version: 1.0n"
. "Content-Type: text/html; charset={$charset}n";

/** end HTML patch */

Thanks,
-Chris
 Quote

Status: offline

ChrisN

Forum User
Newbie
Registered: 01/25/04
Posts: 3
An update, in case anybody else cares about this.

The below hack worked. I also had to insert some <P> and <A> tags and arguments to make the email formatting come out the way I wanted it, with working links. I assume this breaks the plain text digest email, but I accept that because I only intend to send out HTML digests.

Here is my hacked version of COM_emailUserTopics (in lib-common.php). In posting it here, I can see that some of the escape characters aren't being displayed, so email me if you want a copy of it:

function COM_emailUserTopics()
{
global $_CONF, $_TABLES, $LANG08, $LANG24;

$subject = strip_tags( $_CONF['site_name'] . $LANG08[30] . strftime( '%Y-%m-%d', time() ));

$authors = array();

// Get users who want stories emailed to them
$usersql = "SELECT username,email,etids,{$_TABLES['users']}.uid AS uuid "
. "FROM {$_TABLES['users']}, {$_TABLES['userindex']} "
. "WHERE {$_TABLES['users']}.uid > 1 AND {$_TABLES['userindex']}.uid = {$_TABLES['users']}.uid AND (etids '-'Wink ORDER BY {$_TABLES['users']}.uid";

$users = DB_query( $usersql );
$nrows = DB_numRows( $users );

$lastrun = DB_getItem( $_TABLES['vars'], 'value', "name = 'lastemailedstories'" );

// For each user, pull the stories they want and email it to them
for( $x = 1; $x
{
$U = DB_fetchArray( $users );

$storysql = "SELECT sid,uid,date AS day,title,introtext,bodytext "
. "FROM {$_TABLES['stories']} "
. "WHERE draft_flag = 0 AND date = '{$lastrun}'";

$topicsql = "SELECT tid FROM {$_TABLES['topics']}"
. COM_getPermSQL( 'WHERE', $U['uuid'] );
$tresult = DB_query( $topicsql );
$trows = DB_numRows( $tresult );

if( $trows == 0 )
{
// this user doesn't seem to have access to any topics ...
continue;
}

$TIDS = array();
for( $i = 1; $i
{
$T = DB_fetchArray( $tresult );
$TIDS[] = $T['tid'];
}

if( !empty( $U['etids'] ))
{
$ETIDS = explode( ' ', $U['etids'] );
$TIDS = array_intersect( $TIDS, $ETIDS );
}

if( sizeof( $TIDS ) > 0)
{
$storysql .= " AND (tid IN ('" . implode( "','", $TIDS ) . "'Wink)";
}

$storysql .= COM_getPermSQL( 'AND', $U['uuid'] );
$storysql .= ' ORDER BY featured DESC, date DESC';

$stories = DB_query( $storysql );
$nsrows = DB_numRows( $stories );

if( $nsrows == 0 )
{
// If no new stories where pulled for this user, continue with next
continue;
}

$mailtext = $LANG08[29] . strftime( $_CONF['shortdate'], time() ) . "n";

for( $y = 0; $y
{
// Loop through stories building the requested email message
$S = DB_fetchArray( $stories );

$mailtext .= "n<P>------------------------------nn";
$mailtext .= "<P>$LANG08[31]: "
. COM_undoSpecialChars( stripslashes( $S['title'] )) . "n";
if( $_CONF['contributedbyline'] == 1 )
{
if( empty( $authors[$S['uid']] ))
{
$storyauthor = DB_getItem( $_TABLES['users'], 'username', "uid = '{$S['uid']}'" );
$authors[$S['uid']] = $storyauthor;
}
else
{
$storyauthor = $authors[$S['uid']];
}
$mailtext .= "<BR>$LANG24[7]: " . $storyauthor . "n";
}

$mailtext .= "<BR>$LANG08[32]: " . strftime( $_CONF['date'], strtotime( $S['day' ])) . "nn";

if( $_CONF['emailstorieslength'] > 0 )
{
/** old version ckn
* $storytext = COM_undoSpecialChars( strip_tags( PLG_replaceTags( stripslashes( $S['introtext'] ))));
*/
/** hacked version ckn */
$storytext = COM_undoSpecialChars( PLG_replaceTags( stripslashes( $S['introtext'] )));

if( $_CONF['emailstorieslength'] > 1 )
{
if( strlen( $storytext ) > $_CONF['emailstorieslength'] )
{
$storytext = substr( $storytext, 0, $_CONF['emailstorieslength'] ) . '...';
}
}

$mailtext .= "<P>" . $storytext . "nn";
}

$mailtext .= "<P>" . $LANG08[33] . " <A />
. '/article.php?story=' . $S['sid'] ) . ">" . COM_buildUrl( $_CONF['site_url']
. '/article.php?story=' . $S['sid'] ) . "</A>n";
}

$mailtext .= "<P>n------------------------------n";
$mailtext .= "<P>n$LANG08[34]n";
$mailtext .= "<P>n------------------------------n";

$mailto = $U['username'] . ' ';

COM_mail( $mailto, $subject, $mailtext );
}

DB_query( "UPDATE {$_TABLES['vars']} SET value = NOW() WHERE name = 'lastemailedstories'" );
}
 Quote

Status: offline

::Ben

Forum User
Full Member
Registered: 01/14/05
Posts: 1569
Location:la rochelle, France
Code is nicer with bbcode Smile
Text Formatted Code


[ code ] [ /code ]
 

I'm available to customise your themes or plugins for your Geeklog CMS
 Quote

Status: offline

::Ben

Forum User
Full Member
Registered: 01/14/05
Posts: 1569
Location:la rochelle, France
A solution :

Make a call from a new emailgeeklogstories_html.sh to a daily_digest_html.php where mail are send in html format.

See sources here

::Ben
I'm available to customise your themes or plugins for your Geeklog CMS
 Quote

All times are EDT. The time is now 08:18 am.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content