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

eZ debug

Timing: Jan 18 2025 05:12:52
Script start
Timing: Jan 18 2025 05:12:52
Module start 'content'
Timing: Jan 18 2025 05:12:52
Module end 'content'
Timing: Jan 18 2025 05:12:52
Script end

Main resources:

Total runtime0.2447 sec
Peak memory usage2,048.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0082 587.8438180.8125
Module start 'content' 0.00820.0059 768.656398.0547
Module end 'content' 0.01410.2304 866.7109527.1250
Script end 0.2446  1,393.8359 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00381.5567200.0002
Check MTime0.00150.6023200.0001
Mysql Total
Database connection0.00070.282010.0007
Mysqli_queries0.195479.86871410.0014
Looping result0.00130.54371390.0000
Template Total0.230194.010.2301
Template load0.00100.416510.0010
Template processing0.229193.616810.2291
Override
Cache load0.00070.278310.0007
Sytem overhead
Fetch class attribute can translate value0.00070.286510.0007
XML
Image XML parsing0.00030.124610.0003
General
dbfile0.00170.6919200.0001
String conversion0.00000.002830.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs