ez.no / ezpublish / documentation / customization / components / information collection
These documentation pages are no longer maintained. Please visit the new documentation site.
Information collection allows eZ publish to collect information from a form and send it by e-mail.
To do this you can create a class (for example "feedback") with the following attributes: name, description, subject and message. Set the attributes subject and message as information collectors. These attributes will be used to collect information, while the others (name and description) will be used internally by the webmaster in order to assign a unique name and a description text.
When viewing an object of this class, the system will display the subject and message attributes as text fields. eZ publish will collect the information that is inputted into these fields and send it by e-mail when the user hits the "Send" button. The e-mail will be sent to an address specified within a site.ini configuration file (or an override).
In order to set a form for collecting information and send it by email you need to follow this steps:
Create a class called "feedback", for example, with the following attributes:
The attributes subject and message must be checked as "information collectors", this way eZ publish knows that the information inputted in this attributes is going to be collected to be sent by email.
In the file 'settings/siteaccess/my_site/site.ini.append.php' you must specify who is going to be the e-mail reciver:
[InformationCollectionSettings] EmailReceiver=webmaster@example.com
In addition, it is also possible to specify the sender's address:
[MailSettings] EmailSender=division@example.com
Keep in mind that settings in "settings/override/site.ini.append" will override the default and also your siteaccess settings.
Create and object of the class "feedback" and put it somewhere in the contents of your site. When creating this object you only need to specify the name and the description of the object. For example, you can create and object and set the attribute name as "Customers Feedback Form" and set the attribute description as "Here you can add your comments about the quality of service you have receive".
Now you can create the override template for the class "feedback" to be used when viewing objects of this class, this template must be located in 'design/my_site/override/templates'. Here you can see an example (myfeedback.tpl) of how this template would look like:
<div class="content-view-full"> <div class="class-feedback-form"> <h1>{$node.name|wash()}</h1> {include name=Validation uri='design:content/collectedinfo_validation.tpl' class='message-warning' validation=$validation collection_attributes=$collection_attributes} <div class="attribute-short"> {attribute_view_gui attribute=$node.object.data_map.description} </div> <form method="post" action={"content/action"|ezurl}> <h2>{"Subject"|i18n("design/base")}</h2> <div class="attribute-subject"> {attribute_view_gui attribute=$node.object.data_map.subject} </div> <h2>{"Message"|i18n("design/base")}</h2> <div class="attribute-message"> {attribute_view_gui attribute=$node.object.data_map.message} </div> <div class="content-action"> <input type="submit" class="defaultbutton" name="ActionCollectInformation" value="{"Send form"|i18n("design/base")}" /> <input type="hidden" name="ContentNodeID" value="{$node.node_id}" /> <input type="hidden" name="ContentObjectID" value="{$node.object.id}" /> <input type="hidden" name="ViewMode" value="full" /> </div> </form> </div> </div>
Now you must specify the override rule for the class "feedback" in the file '/settings/siteaccess/my_site/override.ini.append' in order to tell eZ publish that you want objects of this class to be viewed with the template you just made and not with the default template.
This is what you must specify in the file override.ini.append :
[feedback] Source=node/view/full.tpl MatchFile=myfeedback.tpl Subdir=templates Match[class_identifier]=feedback
After the information is collected an email is going to be created and sent to the receiver's addres specified in the ini file. The template used to create this email is 'design/my_site/override/templates/content/collectinfomail/form.tpl'. If you want your emails to look diferently then you must create an override for this template and place it in 'design/my_site/override/templates/'. Here you can see an example (myfeedback_mail.tpl):
{set-block scope=root variable=subject} {"Collected information from %1"|i18n("design/standard/content/edit", ,array($collection.object.name))} {/set-block} {* Use this line to specify the e-mail in the template, can read this from the object to make it dynamic pr form {set-block scope=root variable=email_receiver}{$object.data_map.reciver.content}{/set-block} *} {* Set this to redirect to another node {set-block scope=root variable=redirect_to_node_id}2{/set-block} *} {"Here are the contents of the feedback form:"|i18n("design/standard/content/edit")} {section name=Attribute loop=$collection.attributes} {$Attribute:item.contentclass_attribute_name|wash}: {attribute_result_gui view=info attribute=$Attribute:item}
Now you want eZ publish to use your new customized template for creating the emails to be sent. For this you must again modify the file '/settings/siteaccess/my_site/override.ini.append' and add the following information:
[feedback_mail] Source=content/collectedinformail/form.tpl MatchFile=myfeedback_mail.tpl Subdir=templates Match[class_identifier]=feedback
After the email has been sent eZ publish is going to display the information that has been collected. The template used to view this information is 'design/my_site/override/templates/content/collectinfo/form.tpl'. If you want this page to look diferent then you must create an override for this template and place it in 'design/my_site/override/templates/'. You can call this file for example 'mycollected_form.tpl'.
Finally, you must specify the override rule for the template if you want eZ publish to use your new customized template for displaying the collected information. For this you must again modify the file '/settings/siteaccess/my_site/override.ini.append'. You must know the number that identifies the class "feedback", this number is the class id and you can see it in the admin interface of your site. Then you must add the following information to the file:
[collected_feedback_form] Source=content/collectedinfo/form.tpl MatchFile=mycollected_form.tpl Subdir=templates Match[class]= 'class_id'
Comments
step 6 - overriding the template that creates the email
Dan Ruth
Monday 06 November 2006 9:34:10 pm
design/standard/templates/content/collectedinfomail/feedback.tpl as opposed to form.tpl as mentioned in step 6
no header?
ole poulsen
Friday 28 April 2006 1:01:36 pm
I have named my fields (in the class) "subject", "realname" and "email" but they do not have those functions. Why not? And how do I get email-header-information?
ContentObjectAttribute_ezstring_data_text_???
ole poulsen
Tuesday 25 April 2006 3:40:41 pm
<input class="box" type="text" size="70" name="ContentObjectAttribute_ezstring_data_text_3097" value="" /
???
It is of course the name-attribute that I dont quite get. Normally those attributes in a contact form would be called "realname", "email" and "subject" etc... but here they apparently get some automatically generated value - that DOESNT work... at least not for me at the moment.
My emails get send and received allright. But there is no realname, email or subject information in the relevant places.
What to do?
Problems with final email form
Zak dma
Friday 07 April 2006 3:47:13 pm
[collected_feedback_form]
Source=content/collectedinfo/form.tpl
MatchFile=my_form1.tpl
Subdir=templates
Match[class]=27
27 - ID of my feedback class
But after sending mail, EZPublish use standard form (not my my_form1.tpl) to display sent information. Why?
size for input type=text elements
Oriol Bausà
Thursday 22 December 2005 4:18:01 pm
How to access the collected informations
Xavier Dutoit
Friday 01 April 2005 7:37:29 pm
content/collectedinfo/[nodeid]
With the infamous 42 node id ;), you then get:
http://ez.no/content/collectedinfo/42
typo: mesage should be message
nigel dodd
Tuesday 14 December 2004 11:37:34 am
Should read:
where now the data_map.message is spelt correctly.