Forums / Developer / Challenge: Uniqueness at an asttribute's value

Challenge: Uniqueness at an asttribute's value

Author Message

Jorge estévez

Wednesday 24 September 2008 8:58:58 am

Hi to all,

I need to have an attribute of a class to be unique in it's value in the administration site.

My site has many products each with a unique code, at the admin site I would like to let other introduce instances of the product class but when inserting the code value they shoúld get an error if the code has been already entered (when they press the acept button send for publication)

The only idea I have is to have the attribute to be unique at the database and get the error when trying to insert the information but this does not seems the right thing to do... (messing with the database)

Uniqueness at the code attr. is needed whe inserting data in de admin site, this is a must.

thanks fot new ideas!

Diseño Web Cuba
Web Design Cuba
www.elfosdesign.com

Piotrek Karaś

Wednesday 24 September 2008 9:52:30 am

Hi Jorge,

Try this, one of my first ones ;)
http://ez.no/developer/contribs/datatypes/ez_unique_datatypes

Good luck,
Piotrek

--
Company: mediaSELF Sp. z o.o., http://www.mediaself.pl
eZ references: http://ez.no/partners/worldwide_partners/mediaself
eZ certified developer: http://ez.no/certification/verify/272585
eZ blog: http://ez.ryba.eu

Jorge estévez

Wednesday 24 September 2008 10:04:16 am

Thanks

I am using ez 310, and the extension is meant for 4.X

is there some way I could use it for 3.10

thanks again!

Diseño Web Cuba
Web Design Cuba
www.elfosdesign.com

Piotrek Karaś

Wednesday 24 September 2008 10:13:24 am

Yup, upgrade as soon as possible ;)

And if that's impossible, I don't remember exactly, but I don't think there is any advanced object-oriented PHP code inside, so it should be quite moveable backwards with little effort. I don't plan anything like that, though ;)

--
Company: mediaSELF Sp. z o.o., http://www.mediaself.pl
eZ references: http://ez.no/partners/worldwide_partners/mediaself
eZ certified developer: http://ez.no/certification/verify/272585
eZ blog: http://ez.ryba.eu

Jorge estévez

Sunday 28 September 2008 3:14:59 am

I will change the code...

thanks

Diseño Web Cuba
Web Design Cuba
www.elfosdesign.com

Jorge estévez

Friday 03 October 2008 3:54:51 am

Hi again,

Sorry to bother, the only thing I cannot find how to "traslate" to php4 are codes in the following form:

return eZInputValidator::STATE_INVALID;
return self::validateUniqueStringHTTPInput( $data, $contentObjectAttribute );
eZDataType::register( eZUniqueStringType::DATA_TYPE_STRING, "eZUniqueStringType" );

Can you spare 3 minutes please and transfrom the lines that has "::" to whatever php4 needs.

Thanks

Diseño Web Cuba
Web Design Cuba
www.elfosdesign.com

Piotrek Karaś

Friday 03 October 2008 11:47:59 am

return eZInputValidator::STATE_INVALID;
eZDataType::register( eZUniqueStringType::DATA_TYPE_STRING, "eZUniqueStringType" );

These two you should be able to look up in any built-in datatype of 3.x, and those are located in /kernel/classes/datatypes/...

return self::validateUniqueStringHTTPInput( $data, $contentObjectAttribute );

This should work in both versions, you may try to substitute self:: with proper class name.

Sorry, but I've never written PHP for 3.x...

--
Company: mediaSELF Sp. z o.o., http://www.mediaself.pl
eZ references: http://ez.no/partners/worldwide_partners/mediaself
eZ certified developer: http://ez.no/certification/verify/272585
eZ blog: http://ez.ryba.eu

Jorge estévez

Tuesday 07 October 2008 4:36:43 am

Hello

Just can't find the right traslation to php 4.x code for ez 3.10, if someone could help with this, i does not seem so difficult but my lack of knowledge with php wont get me the results expected (be able to use it with ez 3.10)

any help will make my day, week and month!

thanks

Diseño Web Cuba
Web Design Cuba
www.elfosdesign.com

eZ debug

Timing: Jan 31 2025 03:35:46
Script start
Timing: Jan 31 2025 03:35:46
Module start 'content'
Timing: Jan 31 2025 03:35:46
Module end 'content'
Timing: Jan 31 2025 03:35:46
Script end

Main resources:

Total runtime0.3390 sec
Peak memory usage8,192.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0076 588.0625370.2734
Module start 'content' 0.00760.0140 958.33591,009.7031
Module end 'content' 0.02160.3173 1,968.03913,898.2891
Script end 0.3390  5,866.3281 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00461.3660200.0002
Check MTime0.00140.4035200.0001
Mysql Total
Database connection0.00090.256910.0009
Mysqli_queries0.231868.36381410.0016
Looping result0.00150.43321390.0000
Template Total0.316993.510.3169
Template load0.00090.271010.0009
Template processing0.316093.204910.3160
Override
Cache load0.00060.188810.0006
Sytem overhead
Fetch class attribute can translate value0.00160.480510.0016
XML
Image XML parsing0.00020.070510.0002
General
dbfile0.00902.6415200.0004
String conversion0.00000.002130.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