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.

[2.0] Automatically increase "counter" field in the CP

March 04, 2010 12:27pm

Subscribe [2]
  • #1 / Mar 04, 2010 12:27pm

    Comptroller

    69 posts

    Note: This is for EE 2.0!

    I am going to use EE 2 as a media database (books, mainly) in a project. I’ve mapped it all out, custom fields, various channels and relationships, all working fine.

    Every piece needs a unique id number, though. I am using a db field for that, too, and while this works it means that I have to a) check for the latest number, b) mentally increment that and c) enter it manually in the CP. What’s worse, if I accidentally re-use a number EE won’t warn me.

    Ideally I could have this field pre-filled with a new number when creating a new entry. This is trivial using a little PHP + SQL, but unfortunately I can’t easily use a CP extension in 2.0, and I’d rather not use an SAEF just because of that.

    Any ideas? Am I making sense? I have heard about using “view” files, somebody got more info on that?

  • #2 / Mar 04, 2010 12:53pm

    ender

    1644 posts

    is the entry_id not sufficient?  it’s definitely unique to your database.

  • #3 / Mar 04, 2010 1:13pm

    Comptroller

    69 posts

    Ah, I had wanted to mention that: yes, I had toyed with using the entry_id, but it’s not a good fit, there are other channels in the setup, too, and if I’d ever have to split it off or merge it with another db it’d be a nightmare. So, bottom line, I’d rather not use entry_ids for that purpose.

  • #4 / Mar 04, 2010 2:16pm

    Mark Bowen

    12637 posts

    If you can’t use the entry_id due to export / import limitations then you could probably always write a custom extension that would take the entry_id and simply place it into a custom field in your weblog. This could then be used instead maybe?

    Best wishes,

    Mark

  • #5 / Mar 04, 2010 2:44pm

    Comptroller

    69 posts

    In 1.6.8 I’d take a somewhat similar approach, but since this is 2.0, I’m not sure the necessary hooks are in place in the CP for such an extension?

  • #6 / Mar 04, 2010 2:54pm

    Mark Bowen

    12637 posts

    In 1.6.8 I’d take a somewhat similar approach, but since this is 2.0, I’m not sure the necessary hooks are in place in the CP for such an extension?

    Oops sorry must have read your OP too fast as I didn’t see you were using 2.0. Sorry about that :-(

    Looking at the documentation for 2.0 if I’m right in my thinking then I think it might be doable although to tell the truth hooks are not my best area of expertise.

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

ExpressionEngine News!

#eecms, #events, #releases