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.

Automatically submit a SAEF

July 07, 2009 10:54am

Subscribe [2]
  • #1 / Jul 07, 2009 10:54am

    benniog

    37 posts

    Hi,
    I want to know how to automically submit a SAEF using hidden fields. Why? I want to track what files a registered user is downloading, so I have created a weblog called “user_downloads” with two custom fields, “user” and “download_file”. When one of my registered users accesses a members only page I want to submit the relevant data into my “user_downloads” weblog, I dont want the user to know that this is happening.

    The only way that I can think of doing this is by creating a SAEF that contains hidden fields and submitting it using some JavaScript i.e.

    The template code:

    {exp:weblog:entry_form weblog="user_downloads"}
          <input type="hidden" name="user" id="user" value="{username}" />
          <input type="hidden" name="download_file" id="user" value="name of download file" />
    {/exp:weblog:entry_form}

    The JQuery:

    $("#entryform").submit();

    Is this the best/only way of achieving this?

    Thanks in advance
    Gary

  • #2 / Jul 07, 2009 10:57am

    Ingmar

    29245 posts

    This looks like a rather roundabout way of doing this. Have you looked into other solutions, like the Linklocker module or something like that? As far as I know it keeps records of downloads as well.

  • #3 / Jul 07, 2009 11:02am

    benniog

    37 posts

    I have looked Linklocker and seems a little heavy duty for what I am trying to do… ideally I dont want to install a module when I only need about 10% of its functionality

  • #4 / Jul 07, 2009 1:04pm

    ender

    1644 posts

    you can do this easily using jquery and google analytics events.

    http://www.carronmedia.com/extend-google-analytics-with-jquery/ has good sample code for this.

    as far as your original question goes… you’d need to swap your .submit() call for something like the jquery form plugin.  this would allow you to post your form to the server as an ajax call that the user is much less likely to notice (because it doesn’t cause a page refresh).  really though, don’t do it this way, it’s huge overkill.

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

ExpressionEngine News!

#eecms, #events, #releases