Given the lack of options for bulk uploading in D7 (so far), I'm very pleased with the work done on this module! I'll definitely do anything I can to help.

I made a few minor UI tweaks in my own implementation and thought I would post them for discussion.

What this patch does:

- Adds "Click here to upload multiple files" link to the descriptions of 'image' and 'file' field types in edit forms.
- Redirects to 'upload_nodes' page instead of homepage.
- More concise wording for upload_nodes/* menu item title and description. It now looks like:

!type (!field)
A new !type node will be created for each file.

(or)

Image (Upload)
A new Image node will be created for each file.

- Adds missing t() wrapper to description noted above.

Thanks, pyrollo!

Comments

othermachines’s picture

StatusFileSize
new11.47 KB

Here's another patch (to replace the first one) that takes things a big step further. I hope you don't mind my dipping right in, but I've got a client who is pretty excited about testing out this module provided there are a few usability improvements. The rest of it works great, which is a relief since it would probably make my brain explode.

What the patch does:

- Changes the user route to the upload form. This is a major change. I've removed the "Upload nodes" link on the content overview page and instead provided direct links to the upload form on the field widgets in the node/add form. The upload form itself is now a local task beneath node/add/%. Short of embedding the upload in the form, this is (I think) where the user would expect to find it. It also puts the upload form into visual context with the node/add form (as a local task), and it gets rid of that extra click. With this change, the 'upload_nodes' page becomes unnecessary so I've removed that, as well.

- Changes final redirect. Priority on final redirect is based on user's original location. A 'redirect' variable in the URL query string keeps track of this (I originally used 'destination' but it caused a conflict somewhere). Defaults to the 'node/add' form. If this for some reason fails (URLs can be manipulated), user is redirected to the content overview page, if permitted; otherwise, to the homepage. NOTE: the 'redirect' variable is simply to add some flexibility for users who may not take the traditional route to the node/add form; e.g. a group member creating group content.

- Changes permissions on config items. Requires permission 'administer site configuration' for all module configuration tasks, including cleanup (previously set to 'access content').

- Integration with OG create permissions module (a selfish move-- I need this :)).

- Adds message to inform the user when moving from upload to edit form: 'Files uploaded successfully! You may now edit each node.'

- Removes upload_nodes_admin_paths() - no longer needed.

- Some wording changes.

Looking forward to getting some feedback. Cheers -

othermachines’s picture

StatusFileSize
new11.82 KB

Nitpicky reroll:

In upload_nodes_field_widget_form_alter(), look for $element[0]['#description'] instead of $element['#description'] if upload limit == 1.

In _upload_nodes_access() missing space in permission argument. (OK, that's kinda important.)

pyrollo’s picture

Thanks for these improvements !

I'm not sure about removing upload_nodes_admin_paths() but there is some work to do on that anyway. There may be several available entry points (for example, a link from a "photo album" node to add "photo" nodes attatched to it).

There is a bug in upload_nodes_field_widget_form_alter : if you have two content types, the link may target the wrong content type.

I guess _upload_nodes_get_target should be used there. Sorry, I don't have much time right now but I'll have a closer look at that later.

othermachines’s picture

Hi, pyrollo. Thanks for the feedback. I'm testing this on a site for a conference that is set to begin tomorrow, so I definitely expect to get some user feedback during the next few days.

#1 - upload_nodes_admin_paths() sets 'upload_nodes', which no longer exists with this patch. Or do you mean you're not sure about removing the page provided at 'upload_nodes'?

Whether a "snapshot" page ('upload_nodes') is needed is up for debate. Can you think of a scenario where a user would need to see all of their enabled fields in a list rather than linking to the /upload page for a field directly? It's possible I just haven't thought of one, yet.

To be clear on how file paths have changed, here's a look at what it may have looked like before:

upload_nodes/article/field_article_image/upload

And now:

node/add/article/field_article_image/upload

To return to the page you were on after uploading:

node/add/article/field_article_image/upload?redirect=node/82

#2 - "bug in upload_nodes_field_widget_form_alter" - Hmm, I wasn't able to duplicate this. The link is built using a modified version of your function _upload_nodes_base_url() which includes the content type id in the link path. I've tested this with multiple content types with the functionality enabled. Maybe I'm misunderstanding?

Cheers-

pyrollo’s picture

Hello Othermachines,

For #1, new paths seem much better than original ones.

I haven't a global vision yet about how the user should get to the upload form. The link you added is a good idea. In my website, I will use only upload_nodes for adding picture so I'll need a more direct link to the upload form. I'll think of that further and maybe open a specific issue to gather ideas about entry points.

You can reproduce #2 by creating two content types using the same field. Lets say ContentType1 and ContentType2, both using Field_Photo. Enable upload_nodes on both content type and go to ContentType2. The link will lead to ContentType1 upload form.

This is because the code checks only the field name (Field_Photo) and returns the first matching target.

Anyway, thanks a lot for your help, I hope to be able to give more feedback soon.

Best regards.

othermachines’s picture

StatusFileSize
new11.88 KB

Opening a specific issue regarding entry points is a good idea.

#2 - I think I get you. Sounds like you're looking at where the loop breaks on a match of field_name, here:

foreach (_upload_nodes_get_managed_targets() as $target) {
  if ($target['field_name'] == $context['field']['field_name']) {
    ...
    break;
  }
}

Is that right?

I'm curious about how you were able to create two fields with the same name. I didn't think this was allowed?

Anyway, wouldn't hurt to check on node type, too. Attaching another patch.

Thanks -

sw3b’s picture

I can confirm those tweaks work on my side also. I think they are a must.

Thanks.

pyrollo’s picture

Status: Active » Fixed

Hello,

I just commited that patch. I guess I'll do some further modifications later.

Thanks again for these improvements !

pyrollo’s picture

I also modified the loop we were discussing about, with a call to _upload_nodes_get_target function.

There is still something I'd like to improve :

When you are in the add node form and click on "Click here to upload multiple files" link, once you have finished to edit each new node, you come back to the blank node form. That's technically correct but functionally, it would be better to get back to a main page.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

othermachines’s picture

Status: Closed (fixed) » Active

HI, pyrollo. Happy to hear my suggestions have been committed! I've downloaded the latest -dev and can confirm that everything works well.

FYI - I've been using the module in production since last October with no problem reports. The site is http://c4d.undg.org

Regarding redirecting to the homepage - this is tricky because you don't know if the user is uploading from the back-end admin or the public site. Ordinarily I wouldn't recommend unexpectedly redirecting the user from admin/ into the public site (or vice-versa), but that wouldn't necessarily be the case. Redirecting to the node/add form just seemed the simplest solution since that is where they started, and it seems to be a common approach. For instance, when you edit content from the Content overview page, after you are finished you are always redirected back to Content overview.

Thanks again for the great work.

pyrollo’s picture

Hi Othermachines,

That's a good news to have this module used on production !!

I'm thinking about other entry points like "Add detail nodes" from a master node unsing node relation (or other master detail mechanism).

sw3b’s picture

Hi, i'm also using it on production site and if you could look at something like node reference widget it will make my day ! For now the users reselect the node reference when they upload images, but if the node reference could be pass to the form it would be awesome !!!

Thanks and good work on this module...

And another suggestion, maybe go with a dev or alpha version could be very useful to make it grow with all the Drupal community.