ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

[Deprecated] DMZ 1.6.2 (DataMapper OverZealous Edition)

November 23, 2009 11:54pm

Subscribe [46]
  • #16 / Dec 04, 2009 12:36pm

    BrianDHall

    760 posts

    Hiya Phil, just came up with something useful to suggest. I would like, and think other people might find it useful, to have a more full _template.php provided with some of the other configuration options available. I just happened upon the part of the manual that explains the custom error wrappers for forms, and at the bottom of Validation page I noticed you could over-ride them on a per-object basis. Just as an example, but if this were provided in commented fashion like with other features shown in the template, I’d have noticed them much sooner 😊

    Would be nice to have any other interesting configuration variables shown in template too, if there should happen to be any. I’m getting to the point that I prefer reading code over reading manuals 😊

  • #17 / Dec 04, 2009 2:08pm

    OverZealous

    1030 posts

    Hi Phil, what do you think of an RSS feed to subscribe for the changelog / version updates?

    Hmmm.  I could look into this.  As it is every time I make an update, though, I have to:
    • Update the manual (and put it on the website)
    • Deprecate the existing forum
    • Create a new forum
    • Re-update the manual with the new forum’s link
    • Update my signature
    • Update the CI wiki

    An RSS feed would just be one more thing to update… 😉

  • #18 / Dec 04, 2009 2:11pm

    OverZealous

    1030 posts

    I would like, and think other people might find it useful, to have a more full _template.php provided with some of the other configuration options available.

    I don’t have the time to flesh it out right now, but if you wanted to add anything you’ve come across and PM or email the update _template.php to me, I’ll include the changes with the next release.

  • #19 / Dec 06, 2009 1:49pm

    janus303

    10 posts

    I am really enjoying the DMZ library thus far. There is a bit of a learning curve, but it’s really worth it.

    There’s a pretty solid library in CI already for dealing with file uploads, but it’s not clear to me if it’s possible to use it with DMZ’s built-in form generation and handling, which I’d like to use to handle all the metadata associated with an uploaded file.

    Would I call the do_upload method as a validation function? If anybody could provide an example of how it might be used or comment on if it’s possible or advisable, that would be great.

    To answer my own question, or at least put it out of its misery, there’s not as much brilliance in the CI file upload class as it seemed, at least for my purposes. I just used PHP’s built-in functionality to handle that part.

     

    As a (tangentially related) side note, this is my first foray into file uploading in a web application, and it’s a user interface nightmare. In the world of desktop applications from which I come, we spend all kinds of effort customizing and hooking into OS file open dialogs to make them do wondrous things like display metadata about our files to the user to help them make an informed decision about what to open. In the web world I can’t even tell the browser’s file open dialog to filter by file type. I know there are some Flash options, but really… why should that be necessary? </rant>

  • #20 / Dec 07, 2009 2:06am

    tdktank59

    322 posts

    Another great release Pill!

    Now I have to go read the docs again… O well, it’s all worth it in the end right?

    Will update if I notice any problems.

  • #21 / Dec 07, 2009 2:39am

    OverZealous

    1030 posts

    Now I have to go read the docs again… O well, it’s all worth it in the end right?

    FYI: you should really only need to read two pages: the Change Log and Upgrading Instructions.

    😉

    1.6.0 -> 1.6.1 is mostly a bugfix.  1.5.x -> 1.6.0 is a major upgrade!

  • #22 / Dec 07, 2009 2:47am

    tdktank59

    322 posts

    yeah im still at the 1.5.3 so im reading the 1.6.0 update lol

    I know but its still the processes of learning and using the new functionality (when needed)

    edit: btw I normaly do read the change log to see what you did lol

  • #23 / Dec 07, 2009 2:50am

    OverZealous

    1030 posts

    I figured you did.  I just like to ... um ... reinforce the existence of certain aspects of the docs. 😊

  • #24 / Dec 07, 2009 2:58am

    tdktank59

    322 posts

    I figured you did.  I just like to ... um ... reinforce the existence of certain aspects of the docs. 😊

    Yeah I think after the second time you “um ... reinforced the existence” of them I’ve started going there first to find my answers then coming here!

    But yeah I agree, I’ve noticed a lot of well documented/repetitive questions that are easily answered in the technical issues, or some main page of the docs. So reinforcement is good!

    NOTE: I am not saying anyone is lazy/dumb/stupid etc… for asking questions even if they are answered in the docs. I know we all at some points just space and don’t see something right in front of us. Or just need more clarification. (in the later instance provide the knowledge that you know whats going on tho. It helps us save time in helping you.)

  • #25 / Dec 07, 2009 10:01am

    silvergear99

    7 posts

    Hello
    I have been using this Datamapper for a few weeks and its works perfect. Thank you very much.

    But i come up with a problem.

    I have a loginform in the right sidebar.
    And in the main area i have a registerform.

    When I fill in wrong data in the registerform I get two “There was an error saving the form.” Both in the main area and in the sidebar.

    Both forms are rendered from a user model. Is this the problem ?
    I tried using custom templates, like this

    echo $user->render_form(array('username' , 'password' => 'password'),'login/check_login',array('save_button' => 'Log in'),'dmz_htmlform/login_form','dmz_htmlform/login_row','dmz_htmlform/login_section');

    But I have no luck,

  • #26 / Dec 07, 2009 5:54pm

    BrianDHall

    760 posts

    Say, what’s a good way of dealing with validation where a field is only used on creating a new object - but is otherwise never used?

    I want to use a password_confirm field to control account creation, but obviously beyond account creation it is never used. I’m probably just going to hack a custom validation rule that checks $this->id, or use a bit of controller logic - but is there a better way to handle this that is eluding me?

  • #27 / Dec 07, 2009 6:26pm

    OverZealous

    1030 posts

    Both forms are rendered from a user model. Is this the problem ?

    If they are the same user model, then yes, because the validation is done on the object itself, and the errors are tracked on the object.

    I assume that after the user attempts to login with the sidebar, they are redirected to the “normal” login page, correct?  If so, simply create a new, empty User object to use for rendering the sidebar, or, alternatively, create an empty user for the registration page (since logically the user is new).

    But the error messages shouldn’t be shared across two different user objects.

  • #28 / Dec 07, 2009 6:38pm

    OverZealous

    1030 posts

    I want to use a password_confirm field to control account creation, but obviously beyond account creation it is never used.

    In this specific example, you don’t need to make it complicated.  If you use matches and required on a password_confirm field, DMZ will automatically fill in the virtual password_confirm field when loading an existing object.  The only time you need to do something special is when programmatically changing the password (like a generated password); then you’ll need to set both.

    Besides, can’t the user change the password at a later date?  They’ll need a password_confirm then, too.

    —————

    But, if you still want to create an only-required-when-new field, you’ll probably need to do this:

    1) Create a custom required method on your object, that has a specific check for the confirmation field:

    function required($field) {
        if($field == 'password_confirm' && $this->exists()) {
            // You could try setting password_confirm here
            // This may not work if you are properly encrypting the password!
            // $this->password_confirm = $this->password;
            return TRUE;
        } else {
            return parent::required($field);
        }
    }

    2) For any other validation rules used on that field, you’ll probably need to override them like above.  (You might even want to add a method for doing the field/exists check, so you aren’t copying and pasting code all over.)

    —————

    I might add (yet another) validation rule required_when_new that handles this internally.  It’s an easy addition.

  • #29 / Dec 08, 2009 1:35am

    someoneinomaha

    14 posts

    I apologize if this is covered in the guide. I didn’t find it, but maybe I wasn’t looking in the right place.

    I’m wondering if there is a way to get the count of related items without going to the database.

    So I have a user object that has a has_many relationship with an alias object. I get the collection of aliases by $user->alias->get(); But once I have that collection, it seems to me that I should be able to get the count of aliases by determining the number of records in the collection.

    Is there a best practice way to accomplish this with DataMapper OverZealous and Codeigniter?

    $user->alias->count() works, but goes to the database. If that’s the best way to get the data I need, that’s cool.

    Thanks for your time & for the great library.

  • #30 / Dec 08, 2009 1:38am

    OverZealous

    1030 posts

    @someoneinomaha
    Just use PHP!

    $count = count($user->alias->all);

    I’m pretty sure there are examples of this in the DB docs.

    Update: Added this to the count documentation.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases