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

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

eZ debug

Timing: Jan 30 2025 22:22:01
Script start
Timing: Jan 30 2025 22:22:01
Module start 'layout'
Timing: Jan 30 2025 22:22:01
Module start 'content'
Timing: Jan 30 2025 22:22:03
Module end 'content'
Timing: Jan 30 2025 22:22:03
Script end

Main resources:

Total runtime1.2128 sec
Peak memory usage8,192.0000 KB
Database Queries60

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0070 588.2656151.2266
Module start 'layout' 0.00700.0047 739.4922220.7188
Module start 'content' 0.01171.2000 960.21094,472.6328
Module end 'content' 1.21170.0010 5,432.843811.8125
Script end 1.2127  5,444.6563 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00420.3466160.0003
Check MTime0.00200.1629160.0001
Mysql Total
Database connection0.00100.079310.0010
Mysqli_queries1.101890.8510600.0184
Looping result0.00060.0515580.0000
Template Total1.140894.120.5704
Template load0.00350.292520.0018
Template processing1.137393.773620.5686
Template load and register function0.00120.096410.0012
states
state_id_array0.00830.686710.0083
state_identifier_array0.00200.165020.0010
Override
Cache load0.00310.2574370.0001
Sytem overhead
Fetch class attribute can translate value0.00180.147920.0009
Fetch class attribute name0.00220.183560.0004
XML
Image XML parsing0.00390.323020.0020
class_abstraction
Instantiating content class attribute0.00000.001680.0000
General
dbfile0.00890.7311220.0004
String conversion0.00000.000640.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
4content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
4content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
12content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
4content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
4content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 30
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs