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.

Get "author_id" of current entry inside of an extension

March 03, 2010 5:08am

Subscribe [1]
  • #1 / Mar 03, 2010 5:08am

    RealityDesign

    70 posts

    I’m trying to modify the nGen File Field extension to make it create a separate folder for each author’s uploads.  Basically, I just want to add the “author_id” to the end of the “server_path.”

    I have it working fine with a variable that I set with a static value for right now.  For example, instead of the path being “.../images/uploads/”  I can set it to “.../images/uploads/12345/”

    Now I just need to know how I can get the author_id from within the extension.  Is there some class or function to get this information?

  • #2 / Mar 03, 2010 1:41pm

    RealityDesign

    70 posts

    Maybe I over-complicated things in my previous post.  Simply:

    Is there a {author_id} equivalent for extensions?


    I’d be happy to do an SQL query to find the author_id, but I would need to do a “WHERE entry_id = X” but I don’t know how to get X either from within an extension.

    So how can I get the current entry_id or author_id from within an extension?

  • #3 / Mar 03, 2010 2:28pm

    ender

    1644 posts

    the file field is a fieldframe extension, check the fieldframe developer docs:

    http://pixelandtonic.com/fieldframe/docs/functions-reference#save_field

  • #4 / Mar 03, 2010 3:33pm

    RealityDesign

    70 posts

    I shouldn’t have even mentioned the extension I’m trying to modify.  I’m just wondering how you get the current entry_id (or author_id, doesn’t matter) if I was writing an extension from scratch.  There has to be a built-in EE function to do this.

    It seems like the entry_id is always available as GET or POST data in some way or another, so I may just resort to that.  But it seems like EE already has this information when the extensions load, and I should be able to just retrieve it.

  • #5 / Mar 03, 2010 3:53pm

    RealityDesign

    70 posts

    I’ve resorted to just using GET and POST data for the entry_id, checking which one is set, and then using that to query the author_id.  Seems to work well.

  • #6 / Mar 04, 2010 9:44am

    ender

    1644 posts

    my point was that the data your extension has access to depends on the hook it is fired from. many hooks supply a $data array.

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

ExpressionEngine News!

#eecms, #events, #releases