Forums / Setup & design / Using search results to create email lists

Using search results to create email lists

Author Message

Richard Lundberg

Monday 22 September 2008 5:48:01 am

Hi,

I am creating a website for a members organisation. I have created a custom class that contains data on each member, one attribute of this class is an email address.
I have created a custom search that searches only this class and allows visitors locate all members that have a certain common interest for example.

What I want to do now, it to use the results of that search, specifically the email attribute, to create a temporary mailing list to which a form can be sent. Ideally I would like the search results page to have a button that says, "send enquiry to these members" which clicks through to an enquiry from, that when sent only goes to the members detailed in the search results.

Is this possible?
Can specific search results be made available to the form processing template, in /content/collectedinfomail?

Can someone give me some pointers?

thanks in advance,

Richard Lundberg.

 

www.peakm3.com

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