Kennisbank > cms made simple > CMS Made Simple: get the Newsletter Made Simple (NMS) module to send out attachments

CMS Made Simple: get the Newsletter Made Simple (NMS) module to send out attachments

Ferdi Verlaan

Ferdi Verlaan

Manager OTC & NOC

We have a customer who sends out newsletters as an PDF attachment. NMS is capable of sending these attachments within the module itselve, but only from the root. In this case we would like to use the /uploads/pdf folder.

My workaround for the attachment dir bug;

Open /modules/CGExtensions/CGExtensions.module.php:

locate the function ‘CreateFileDropdown’ and change the code to:
* A convenience function to create a file dropdown
*/
function CreateFileDropdown($id,$name,$selectedfile=”,$dir = ”,$extensions =
”,$allownone = ”,$allowmultiple = false,$size = 3)
{
$config = cmsms()->GetConfig();

if( startswith( $dir, ‘.’ ) ) $dir = ”;
if( $dir == ” ) $dir = $config[‘image_uploads_path’];
if( !is_dir($dir) ) $dir = cms_join_path($config[‘uploads_path’],$dir);

if( $extensions == ” ) $extensions =
$this->GetPreference(‘fileextensions’,”);

$tmp = cge_dir::get_file_list($dir,$extensions);
$tmp2 = array();
if( !empty($allownone) ) $tmp2[$this->Lang(‘none’)] = ”;
$filelist = array_merge($tmp2,$tmp);

if( $allowmultiple ) {
if( !endswith($name,'[]’) ) $name .= ‘[]’;
return $this->CreateInputSelectList($id,$name,$filelist,array(),$size);
}
return $this->CreateInputDropdown($id,$name,$filelist,-1,$selectedfile);
}

In /modules/NMS/action.compose.message.php; locate the string ‘case:
‘attachment” and replace complete section with:

case ‘attachment’:
// a file selector dropdown?
$content = ”;
if( isset($blockvalues[$safe_name]) ) {
$content = $blockvalues[$safe_name];
}
if( isset($params[$obj->name]) ) {
$content = trim($params[$obj->name]);
}
//$cgextensions = $this->GetModuleInstance(‘CGExtensions’);
//$obj->control =
$cgextensions->CreateFileDropdown($id,$obj->name,$content,”,”,1);
$dir = ”;
if( isset($keyval[‘dir’]) ) {
$dir = $keyval[‘dir’];
$obj->dir = $dir;
}
$cgextensions = $this->GetModuleInstance(‘CGExtensions’);
$obj->control =
$cgextensions->CreateFileDropdown($id,$obj->name,$content,$dir,”,1);

break;

Now the dir function works, only relative to the /uploads folder, but works
nevertheless. Make sure in the CGExtensions module that the extension is allowed
to be uploaded/used.

And to make it work with sending the newsletter don’t forget the following in /modules/NMS/NMS.modules.php locate the code:

foreach( $this->attached_files as $onefile ) {
echo $onefile;
$fn = cms_join_path($config[‘uploads_path’],$onefile);
$mailer->AddAttachment($fn,$onefile);
}

I’ve just manually changed the path to the path i need, for example:

foreach( $this->attached_files as $onefile ) {
echo $onefile;
$fn = cms_join_path($config[‘uploads_path’].’/PDF’,$onefile);
$mailer->AddAttachment($fn,$onefile);
}

Ferdi Verlaan

Over de auteur

Ferdi Verlaan

Werkzaam bij AASHQ sinds 2005, beheert en inspireert Ferdi een team van uitstekende ontwikkelaars, systeem- en netwerkingenieurs.

Hij is bedreven in verschillende programmeertalen maar ook zeer kundig in zowel Windows (Server) als Linux-besturingssystemen.

Ook interessante artikelen

Deze artikelen kunnen jou ook misschien aanspreken

woensdag 26 april 2023

De snelheid van onze nieuwe website

Ferdi Verlaan

Ferdi Verlaan

Manager OTC & NOC

Ferdi Verlaan

Ferdi Verlaan

Manager OTC & NOC

Neem contact met ons op

En breng jouw IT omgeving ook naar 'the next level'.

Neem contact op