Path

ez.no / ezpublish / documentation / customization / components / information collection


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).

How to use information collection

In order to set a form for collecting information and send it by email you need to follow this steps:

1- Create a class

Create a class called "feedback", for example, with the following attributes:

  • name - a name to identify the form.
  • description - to specify what the form is for.
  • subject - the subject of the message.
  • message - the contents.

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.

2- Configure the ini file

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.

3- Create an object of the class

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".

4- Create the override template

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>

5- Specify the override rule

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

6- Create the override template to send the emails

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}

7- Specify the override rule for the emails

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

8- Create the template to view the information collected

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

not sure if this has changed with newer versions but i could not affect the behaviour/receiver of the email until i overrode

design/standard/templates/content/collectedinfomail/feedback.tpl as opposed to form.tpl as mentioned in step 6

no header?

why does the emails not get any header-information?

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_???

What is this supposed to mean - that is the result i get in the source code of the contact form after having followed the guide here.

<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

I created template my_form1.tpl and add to override.ini.append.php
[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

how can I set a size for the text elements different from 70?

How to access the collected informations

Just add to the url:
content/collectedinfo/[nodeid]

With the infamous 42 node id ;), you then get:

http://ez.no/content/collectedinfo/42

typo: mesage should be message

In the myfeedback.tpl code



       <div class="attribute-message">


               {attribute_view_gui attribute=$node.object.data_map.mesage}


       </div>



Should read:



       <div class="attribute-message">


               {attribute_view_gui attribute=$node.object.data_map.message}


       </div>



where now the data_map.message is spelt correctly.

Contents

Customization

Access control
eZ publish API Documentation
Content structure
Custom design
Components
    Images
    Datatypes
    Shop
    Information collection
    Search
    Form processing
    Error handling
    Icons
    Menus
    Toolbars
Tips & Tricks
Troubleshooting


Created

08/07/2003
2:22:56 pm
by Bård Farstad

Last updated

15/12/2004
10:38:43 am
by Frederik Holljen

Authors

Bård Farstad
Yelitza Jaramillo
Frederik Holljen



This page is part of the eZ Publish documentation. The documentation is available under the GNU Free Documentation License. All contributions will be released under the terms of this license.