censusbv / DitsNews

MODx Revolution Newsletter component
10 stars 5 forks source link

blank newsletter #16

Open physalia opened 13 years ago

physalia commented 13 years ago

I've installed and configured DitsNews 0.2.0 alpha 3. Subscribing/Unsubscribing procedures work well. Cron job is configured and two test subscribers receive the emails: subject OK, but email's body is empty (totally). The template for newsletter's test doc is the suggested one, without changes. The doc contains a simple text line (a welcome message). Friendly URLs is enabled. I've tried to exchange two lines in ditsnews.class.php:

$site_url = $dom->getElementsByTagName('base')->item(0)->getAttribute('href'); / $site_url = $this->modx->getOption('site_url');

as with the original order Cron reported this error: "Fatal error: Call to a member function getAttribute() on a non-object (...)". It seems there is a problem in retrieving/resolving the site URL: maybe it is a provider-related problem (servwise.com), but I've no idea how to fix it.

physalia commented 13 years ago

I didn't understand where in the code is the ID reference related to the document that has to be sent as newsletter. In ditsnews.class.php there are vars to manipulate DB content like message and subscriber's data, that I could find in DB records, but I did'nt find any document-ID related reference. I've tried to manually write content in the "message" field (record: modx_ditsnews_newsletters), exchange the lines mentioned above and comment out the line "$message = $dom->saveHTML();" in ditsnews.class.php: the newsletter has been sent and message was readable in the body of the email. Someone can explain to me the code related to the "building" of the message content in the DB record? Thanks!

nklsf commented 12 years ago

i have the same issue ... :(

CaptainPicard commented 12 years ago

I have the same problem. The newsletter is sent but the mail body is emtpty! Has anyone else a solution for this problem?

hesselamann commented 12 years ago

Hello,

I had the same problem but I found a solution... The problem is in the file core/components/ditsnews/processors/mgr/newsletters/create.php

I tabbed all parts in the code that have to be added/changed. One other very important thing is that your website must be online in the system settings. Success!

<?php
if($doc = $modx->getObject('modResource', $scriptProperties['document'])) {

    function file_get_contents_curl($url) {
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_HEADER, 0);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //Set curl to return the data instead of printing it to the browser.
        curl_setopt($ch, CURLOPT_URL, $url);
        $data = curl_exec($ch);
        curl_close($ch);
        return $data;
    }

$docUrl = preg_replace('/&amp;/', '&', $modx->makeUrl((int)$scriptProperties['document'], '', '&sending=1', 'full') );
$context = $modx->getObject('modContext', array('key' => $doc->get('context_key')));
$contextUrl = $context->getOption('site_url', $modx->getOption('site_url'));
unset($context);

    $message = file_get_contents_curl($docUrl);

$message = str_replace('&#91;&#91;', '[[', $message); //convert entities back to normal placeholders
$message = str_replace('&#93;&#93;', ']]', $message); //convert entities back to normal placeholders