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

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 31 2025 06:13:58
Script start
Timing: Jan 31 2025 06:13:58
Module start 'layout'
Timing: Jan 31 2025 06:13:58
Module start 'content'
Timing: Jan 31 2025 06:13:58
Module end 'content'
Timing: Jan 31 2025 06:13:58
Script end

Main resources:

Total runtime0.0158 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0048 588.2656151.2266
Module start 'layout' 0.00480.0022 739.492236.6797
Module start 'content' 0.00700.0072 776.171998.3125
Module end 'content' 0.01420.0015 874.484441.9922
Script end 0.0157  916.4766 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002314.9066140.0002
Check MTime0.00117.2800140.0001
Mysql Total
Database connection0.00074.283910.0007
Mysqli_queries0.002012.535430.0007
Looping result0.00000.069610.0000
Template Total0.00116.910.0011
Template load0.00085.325010.0008
Template processing0.00021.581310.0002
Override
Cache load0.00063.612010.0006
General
dbfile0.003018.738080.0004
String conversion0.00000.039340.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_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