Friday 08 July 2005 2:23:10 am
1->siteaccess/override/site.ini.append.php
[MailSettings]
ContentType=text/html in [MailSettings]
Transport=sendmail
AdminEmail=laurent@lestudiot.com
EmailSender=
_______________________________________________
2->create class NEWSLETTER
textfield/TITRE XMLtext/CORPS
->create class user : ABONNES NEWSLETTER
Email/EMAIL
textfield/NAME textfield/FIRST NAME
->create class userGroup : Abonnés newsletter
________________________________________________
3->create section newsletter (id 12 e.g) ________________________________________________
4->create à newsletter object in content and take node ID (e.g 332) _______________________________________________________________________ 5->site access/fr/override.ini.append.php
[newsletter_line]
Source=node/view/line.tpl
MatchFile=line/newsletter.tpl
Subdir=templates Match[class_identifier]=newsletter
[page_newsletter]
Source=pagelayout.tpl
MatchFile=page_newsletter.tpl
Subdir=templates Match[section]=12
[full_newsletter]
Source=node/view/full.tpl
MatchFile=full/newsletter.tpl
Subdir=templates
Match[class_identifier]=newsletter _________________________________________________________ 6-> create design/template/line/newsletter.tpl
{* File - Line view *}
<form method="post" action={"content/action"|ezurl}>
<input type="hidden" name="ClassIdentifier" value="abonnes" />
<input type="hidden" name="NodeID" value="332" />
<input class="button new_comment" type="submit" name="NewButton"
value="Créer" />
</form>
<div class="content-view-full">
<div class="class-file">
<h1>{$node.object.data_map.name.content|wash()}</h1>
{section show=$node.object.data_map.description.content.is_empty|not}
<div class="attribute-long">
{attribute_view_gui attribute=$node.object.data_map.description}
</div>
{/section}
<div class="attribute-file">
<p>{attribute_view_gui attribute=$node.object.data_map.file
icon_title=$node.name}</p>
</div>
</div>
_
____________________________________________________________________________ *-> create plain/override/templates/full/newsletter.tpl
{* File - Full view *}
<form method="post" action={"content/action"|ezurl}>
<input type="hidden" name="ClassIdentifier" value="abonnes" />
<input type="hidden" name="NodeID" value="331" />
<input class="button new_comment" type="submit" name="NewButton"
value="Inscription ici" />
</form>
<form method="post" action={"content/action"|ezurl}>
<input type="hidden" name="ContentNodeID" value="314" />
<input type="hidden" name="ContentObjectID" value="314" />
<input class="button new_comment" input type="submit" name="ActionRemove"
value="Desinscription" />
<input type="hidden" name="RedirectURI" value="content/view/full/2" />
</form>
<div class="content-view-full">
<div class="class-file">
<h1>{$node.object.data_map.titre.content|wash()}</h1>
{section show=$node.object.data_map.corps.content.is_empty|not}
<div class="attribute-long">
{attribute_view_gui attribute=$node.object.data_map.corps}
</div>
{/section}
<div class="attribute-file">
<p>{attribute_view_gui attribute=$node.object.data_map.file
icon_title=$node.name}</p>
</div>
</div>
________________________________________________________________________________ 7-> create in design/plain/template:page_newsletter.tpl
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="no" lang="no">
<head>
<style type="text/css">
@import url({"stylesheets/core.css"|ezdesign});
@import url({"stylesheets/site.css"|ezdesign});
@import url({"stylesheets/site-colors.css"|ezdesign});
@import url({"stylesheets/classes.css"|ezdesign});
@import url({"stylesheets/classes-colors.css"|ezdesign});
@import url({"stylesheets/debug.css"|ezdesign});
</style>
{section name=JavaScript loop=ezini( 'JavaScriptSettings', 'JavaScriptList', 'design.ini' )
}
<script language="JavaScript" type="text/javascript" src={concat( 'javascript/',$:item
)|ezdesign}></script>
{/section}
{literal}
<!--[if lt IE 6.0]>
<style>
div#maincontent-design { width: 100%; } /* This is needed to avoid width bug in IE 5.5 */
</style>
<![endif]-->
{/literal}
{include uri="design:page_head.tpl"}
</head>
<body>
<div id="allcontent">
{cache-block keys=$uri_string}
<div id="topcontent">
{let pagedesign=fetch_alias(by_identifier,hash(attr_id,sitestyle_identifier))}
<div id="header">
<div id="header-design">
{menu name=TopMenu}
<a href={"/"|ezurl}><img src={"images/logo.jpg"|ezdesign} alt="retour vers
l'accueil" /></a>
{section show=ezini('Toolbar_top','Tool','toolbar.ini')|count}
<div id="toolbar-top">
<div class="toolbar-design">
{tool_bar name=top view=line}
</div>{* id="toolbar-design" *}
<div class="break"></div>
</div>{* id="toolbar-top" *}
{/section}
</div>{* id="header-design" *}
</div>{* id="header" *}
{/let}
{/cache-block}
{cache-block keys=$uri_string}
<div class="break"></div>
</div>{* id="topcontent" *}
{/cache-block}
<div id="path">
<div id="path-design">
{include uri="design:parts/path.tpl"}
</div>{* id="path-design" *}
</div>{* id="path" *}
{cache-block keys=$uri_string}
<hr class="hide" />
<div id="columns">
{menu name=LeftMenu}
<hr class="hide" />
{/cache-block}
{section show=ezini( 'Toolbar_right', 'Tool', 'toolbar.ini' )|count}
<div id="rightmenu">
<div id="rightmenu-design">
<h3 class="hide">Right menu</h3>
<div id="toolbar-right">
<div class="toolbar-design">
{tool_bar name=right view=full}
</div>{* id="toolbar-design" *}
</div>{* id="toolbar-right" *}
</div>{* id="rightmenu-design" *}
</div>{* id="rightmenu" *}
{/section}
<hr class="hide" />
{cache-block}
{let maincontentstyle='maincontent-bothmenus'}
{section show=eq(ezini('SelectedMenu','LeftMenu','menu.ini'),'')}
{set maincontentstyle='maincontent-noleftmenu'}
{/section}
{section show=ezini('Toolbar_right','Tool','toolbar.ini')|count|eq(0)}
{section show=$maincontentstyle|eq('maincontent-noleftmenu')}
{set maincontentstyle='maincontent-nomenus'}
{section-else}
{set maincontentstyle='maincontent-norightmenu'}
{/section}
{/section}
<div id="maincontent" class="{$maincontentstyle}">
<div id="fix">
<div id="maincontent-design">
{/let}
{/cache-block}
{$module_result.content}
</div>{* id="maincontent-design" *}
<div class="break"></div>
</div>{* id="fix" *}
</div>{* id="maincontent" *}
<div class="break"></div>
</div>{* id="columns" *}
<hr class="hide" />
{section show=ezini('Toolbar_bottom','Tool','toolbar.ini')|count}
<div id="toolbar-bottom">
<div class="toolbar-design">
{tool_bar name=bottom view=line}
</div>{* id="toolbar-design" *}
<div class="break"></div>
</div>{* id="toolbar-bottom" *}
{/section}
<div id="footer">
<div id="footer-design">
<address>{"Powered by %linkStartTag eZ publish® open source content
management system %linkEndTag and development
framework."|i18n("design/base",,hash('%linkStartTag',"<a
href='http://ez.no'>",'%linkEndTag',"</a>" ))}<br
/>{ezini('SiteSettings','MetaDataArray','site.ini').copyright}
</address>
</div>{* id="footer-design" *}
</div>{* id="footer" *}
<div class="break"></div>
</div>{* id="allcontent" *}
<!--DEBUG_REPORT-->
</body>
</html>
_________________________________________________________________________________ 8-> Create kernel/classes/workflowtypes/event/mailinscription/mailinscriptiontype.php
<?php
include_once( "kernel/classes/ezworkflowtype.php" );
define( "EZ_WORKFLOW_TYPE_MAIL_INSCRIPTION", "mailinscription");
class mailInscriptionType extends eZWorkflowEventType
{
/*!
Constructor
*/
function mailInscriptionType()
{
$this->eZWorkflowEventType( EZ_WORKFLOW_TYPE_MAIL_INSCRIPTION,
"Hello User" );
}
function execute( &$process, &$event )
{
$parameters = $process->attribute( 'parameter_list' );
$objectID =& $parameters['object_id'];
$obj =& eZContentObject::fetch($parameters['object_id']);
$classID=& $obj->attribute( 'contentclass_id' );
// if a new receiver
if($classID == '34'){
$data_map=& $obj->attribute( 'data_map' );
$email = $data_map['email']->content();
include_once( 'lib/ezutils/classes/ezmail.php' );
$mail = new eZMail();
include_once( 'lib/ezutils/classes/ezmailtransport.php' );
include_once( "lib/ezutils/classes/ezhttptool.php" );
include_once( "kernel/classes/datatypes/ezuser/ezuser.php" );
include_once( "kernel/classes/ezcontentclassattribute.php" );
include_once( "kernel/classes/ezcontentclass.php" );
include_once( "kernel/classes/ezcontentobject.php" );
$emailSender ='info@izuga.fr.com';
$subject = 'inscription à la newsletter';
$receiver = $email;
$body='Nous avons le plaisir de vous annoncer votre inscription à notre
newsletter';
$mail->setSender( $emailSender );
$mail->setReceiver( $receiver );
$mail->setSubject( $subject );
$mail->setBody( $body );
$mailResult = eZMailTransport::send( $mail );
$process->RedirectUrl = "/";
return EZ_WORKFLOW_TYPE_STATUS_REDIRECT ;
}
//if newsletter edit
elseif($classID == '33'){
$listeAbonnes = eZContentObject::fetchList( true,
array( 'contentclass_id' => 34,
'status' => EZ_CONTENT_OBJECT_STATUS_PUBLISHED)
);
include_once( 'lib/ezutils/classes/ezmail.php' );
include_once( 'lib/ezutils/classes/ezmailtransport.php' );
include_once( "kernel/common/template.php" );
foreach($listeAbonnes as $Abonnes){
$data_map=& $Abonnes->attribute( 'data_map' );
$email = $data_map['email']->content();
include_once( 'kernel/classes/ezcontentobjecttreenode.php' );
$mail = new eZMail();
////////////////////////////////////////////////////////////////////////
$nodeID='332';// newsletter object node // //data_map=titre+corps
$node =& eZContentObjectTreeNode::fetch( $nodeID );
$tpl =& eZTemplate::instance();
//$tpl = & templateInit();
$tpl->setVariable( 'node_id', $nodeID );
$tpl->setVariable( 'node', $node );
$mailTemplateResult =& $tpl->fetch(
'extension/newsletter/design/standard/templates/newsletter/newsletter.tpl' );
$mailTemplateResult=ereg_replace("/var","http://www.isuga.fr/var",$mailTemplateResult);
////////////////////////////////////////////////////////////////////
$emailSender ='info@isuga.fr';
$receiver = $email;
$mail->setBody( $mailTemplateResult);
$mail->setSender( $emailSender );
$mail->setReceiver( $receiver );
$subject = 'Nouvelle Newsletter';
$mail->setSubject( $subject );
$mailResult = eZMailTransport::send( $mail );
//debug - uncomment next 3lines if you want to see what should be in the body
//echo "This is your Mailbody: <plaintext>";
//echo " $mailTemplateResult </plaintext>";
//exit();
}
//return EZ_WORKFLOW_TYPE_STATUS_ACCEPTED;
$process->RedirectUrl = "/";
return EZ_WORKFLOW_TYPE_STATUS_REDIRECT ;
}
else{
return EZ_WORKFLOW_TYPE_STATUS_ACCEPTED;
}
}
}
eZWorkflowEventType::registerType( EZ_WORKFLOW_TYPE_MAIL_INSCRIPTION,
"mailinscriptiontype" );
__________________________________________________________________________________ *-> create in design/plain/override/templates/edit/abonnes.tpl
<form enctype="multipart/form-data" method="post" action={concat( "/content/edit/",
$object.id, "/", $edit_version, "/", $edit_language|not|choose( concat( $edit_language, "/"
), '' ) )|ezurl}>
<table class="layout" width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top">
<div class="maincontentheader">
<h1>{"Edit %1 -
%2"|i18n("design/standard/content/edit",,array($class.name|wash,$object.name|wash))}</h1>
</div>
{include uri="design:content/edit_validation.tpl"}
<input type="hidden" name="MainNodeID" value="{$main_node_id}" />
<br/>
{include uri="design:content/edit_attribute.tpl"}
<br/>
<div class="buttonblock">
<input class="defaultbutton" type="submit" name="PublishButton" value="{'Send for
publishing'|i18n('design/standard/content/edit')}" />
<input class="button" type="submit" name="DiscardButton"
value="{'Discard'|i18n('design/standard/content/edit')}" />
<input type="hidden" name="DiscardConfirm" value="0" />
</div>
</td>
</tr>
</table>
</form>
_
_______________________________________________________________________________ 9->create extension/newsletter/design/standard/templates/newsletter/newsletter.tpl
<div class="content-view-full">
<div class="class-file">
<h1>{$node.object.data_map.titre.content|wash()}</h1>
{$node.object.data_map.corps.content.output.output_text}
</div>
</div>
_____________________________________________________________________________________ 10-> in settings/override/workflow.ini:
add in [eventSettings]
AvailableEventTypes[]=event_mailinscription ______________________________________________________________________________________ 11-> in admin/workflows/standard
create a new workflow process name= "inscription mail"
and choose 'event/hello user' ______________________________________________________________________________________
12-> in admin/triggers
content publish after => choose workflow:inscription mail ________________________________________________________________________________________ 13-> in admin/role&policies create a new group:newsletter choose anonymous/modify policies
and create:
content create class(abonnés newsletter)
content edit class(abonnés newsletter)
content remove class(abonnés newsletter)
_______________________________________________________________________________________
And that'all, It works perfectly
|