Attribute class automatically fill when object is created

Author Message

Albert Balagueró

Monday 18 July 2011 6:08:36 am

Hi,
I would like to know if is it possible that when user creates a new object of a class, this object gets the value of a class attribute automatically. I mean: the user creates an object that have "number" attribute, "title" attribute and "descripction" attribute, is there a way to give the object's "number" attribute automatically a value? The first created, must be 001 (for example), the second, 002; the third, 003; this attribute will increase +1 at each new creation...
Thaks. 

Damien Pobel

Monday 18 July 2011 6:24:17 am

Hi Albert,

If you just want to increment an attribute on each object creation you can add an identifier attribute to your content class and eZ Publish will do the rest automagically ;-)

Cheers

Damien
Planet eZ Publish.fr : http://www.planet-ezpublish.fr
Certification : http://auth.ez.no/certification/verify/372448
Publications about eZ Publish : http://pwet.fr/tags/keywords/weblog/ez_publish

Albert Balagueró

Monday 18 July 2011 6:36:04 am

Hi Damien,
I am ashamed, it was so simple... I didn't know ant test either this class attribute.

Thank you for your fast response.
Cheers! 

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 18 2025 01:57:29
Script start
Timing: Jan 18 2025 01:57:29
Module start 'layout'
Timing: Jan 18 2025 01:57:29
Module start 'content'
Timing: Jan 18 2025 01:57:29
Module end 'content'
Timing: Jan 18 2025 01:57:29
Script end

Main resources:

Total runtime0.6401 sec
Peak memory usage4,096.0000 KB
Database Queries58

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0047 591.3516152.6563
Module start 'layout' 0.00470.0026 744.007839.5156
Module start 'content' 0.00730.6315 783.5234535.3359
Module end 'content' 0.63880.0013 1,318.859412.0938
Script end 0.6401  1,330.9531 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00300.4670160.0002
Check MTime0.00130.1959160.0001
Mysql Total
Database connection0.00060.089210.0006
Mysqli_queries0.596093.0989580.0103
Looping result0.00060.0865560.0000
Template Total0.612095.620.3060
Template load0.00190.296320.0009
Template processing0.610195.306320.3050
Template load and register function0.00040.056910.0004
states
state_id_array0.00080.131710.0008
state_identifier_array0.00110.164420.0005
Override
Cache load0.00160.2483170.0001
Sytem overhead
Fetch class attribute can translate value0.00060.088520.0003
Fetch class attribute name0.00150.231540.0004
XML
Image XML parsing0.00050.075820.0002
class_abstraction
Instantiating content class attribute0.00000.001640.0000
General
dbfile0.00200.3129160.0001
String conversion0.00000.001140.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
3content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
3content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
5content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1content/datatype/view/ezxmltags/link.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/link.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 15
 Number of unique templates used: 7

Time used to render debug report: 0.0002 secs