Using search results to create email lists

Using search results to create email lists

Monday 22 September 2008 5:48:01 am - 3 replies

Author Message

Benjamin Selmer

Friday 26 September 2008 6:53:40 am

To do this you will have to make an extension.

Where to start? Read this article:
http://ez.no/developer/articles/an_introduction_to_developing_ez_publish_extensions

And this one:
http://ezpedia.org/wiki/en/ez/module

Then look at the php classes in the kernel and lib folders in your eZ Publish installation. There are classes there that makes it easy to do both the search and the email sending.

Benjamin Selmer

Friday 26 September 2008 7:15:39 am

To send email from an extension you can use the eZMail class (lib/ezutils/class/ezmail.php).

$mail = new eZMail();
$mail->setSender( 'from-me@mysite.com' );
$mail->setReceiver( 'to-someone@mysite.com' );
$mail->setSubject( 'This is the subject' );
$mail->setBody( 'This is the actual email text.' );

$mailResult = eZMailTransport::send( $mail );

If you want to use a template for the email you can do something like this:

$mail->setBody( $tpl->fetch( "design:mymodule/myview.tpl" ) );

You would have to put that template in extension/myextension/design/standard/mymodule/myview.tpl. Also you must add something like this to the beginning of your php-file for the template to work:

require_once( "kernel/common/template.php" );
$tpl = templateInit();

To fetch a node and some of its child nodes do something like this:

$node = eZContentObjectTreeNode::fetch( nodeID );
$conditions= array( 'Depth' => $maxDepth );
$conditions['ClassFilterType'] = 'include';
$conditions['ClassFilterArray'] = $classArray;
$children = $node->subTree( $conditions );

The conditions array can contain the same conditions that a template fetch function can so you can probably use this method for your search.

I hope this helps.

Richard Lundberg

Friday 26 September 2008 5:13:46 pm

Thanks for the input. It is not a quick fix then. I will certainly look into it though.

www.peakm3.com

You must be logged in to post messages in this topic!

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.