Hi,
thanks for the 6.x release! It works nice for my views, but I'm missing the possibility to sort the entries. For a table style, you can select "sortable" for every selected field. Do you think this could be added to bulk views, too?

Now that I'm able to e.g. delete a bunch of nodes, I'm missing the ability to sort them by their update date to see which are the oldest or the newest nodes etc.

Comments

Frank Steiner’s picture

Assigned: Unassigned » Frank Steiner

Hmm, I tried a little bit around and saw that I would just need to let the view extend the table view instead of the default view, and then the bulk view would react to url parameters like ?order=title&sort=asc. Removing the row plugin and adding the columns options in the form for the bulk style were just one liners, so I guess all it still needs is some theming for clickable column headers.

So I guess I could try to make patch for the bulk view to extend the table view and get all the sort options. Would you consider such a patch, or are there reasons why the bulk view should not inherit from a table view?

infojunkie’s picture

Good point. In fact my next experiment would have been to try to inherit from a table view to reuse all that nice functionality. So by all means please go ahead and try it :-)

Frank Steiner’s picture

StatusFileSize
new5.42 KB

Ok :-) Here's the first try with restricted functionality. It is a table without the column functionality, i.e., every field is shown in one column. Basically it's just like a row plugin with "inline" checked for all fields, but it lets you check the sortable checkbox for every field.

Please test how you like it so far.
Two things from the table view are missing:

  • I didn't enable the table "put fields into columns" functionality yet because it makes the rendering quite complicated. I wasn't able to reuse the preprocess functions for table views from theme.inc because I guess due to that action form I can't mix using a template and the form function you use for selecting actions.
    Therefore I have to rewrite the table theming function in views_node_selector and I didn't try that for the rows (its a lot more complicated due to that column/field stuff.
  • Grouping is enabled, but the table view places a separate header above every group, so that you can e.g. sort inside an author block. I'm not sure how to simulate the mechanism that the table view is using with its templates for views_node_selector function. I will have to try.

So next step would be to enable the column stuff. Let me know if I should go on or if there are problems with this first patch.

cu,
Frank

infojunkie’s picture

That was fast! The patch works well on the whole, I have a few comments:
* When creating a new view with Bulk Ops, I get a warning that:

warning: Invalid argument supplied for foreach() in /home/kratib/www/d6/sites/all/modules/views/includes/plugins.inc on line 3254.

* The options form of the style plugin displays the selected fields in a crooked way. I understand you're still working on that part.
* Concerning the problem of duplicating code from template_preprocess_views_view_table() in our plugin, I would suggest to call the preprocess function from within theme_views_node_selector() and then emulate the table-building code done by views-view-table.tpl.php - adding the form element stuff of course. Does that make sense to you?

Thanks,
K.

Frank Steiner’s picture

Hi Krabit,

thanks for the feedback!

I don't get that error message. Can you tell me what steps you did exactly to create the new view? I might have a special order of selecting style and fields which avoids the error :-)

And I'm not sure about that crooked display. Do you mean the opions form where you can select the sortable fields? Can you send me a screenshot what looks wrong? It looks good here but maybe only with my theme or site style.

About the preprocess function: Actually I tried that, but somehow I failed to transfer the information between views_node_selector and the preprocess function. The preprocess function expected more information in $vars than I had available in $element and somehow I failed to pass more stuff, but maybe I just got confused when thinking too much about it. I will give it a new try. I would like to let the preprocess function to all the work and then just run over the result to add the checkboxes.

Frank Steiner’s picture

Ah, I see my mistake about the preprocess function. Yes, we will be able to use it and just add the checkboxes. Thanks!

Frank Steiner’s picture

StatusFileSize
new3.39 KB

Ok, that was simple :-) After I managed to reuse the templace_preprocess function, everything got very easy. Here's the new patch which gives the bulk plugin all the functionality from the table plugin, including columns, grouping and sticky headers. It also inherits bugs from the table plugin, of course, like the selection which column should be the default sort is saved, but not in the form, so whenever you update the view again, you must re-select your default-sort column. But that's a table plugin issue.

The patch is quite small now. Let me know how it works for you!

infojunkie’s picture

Hey Frank,

Attached is a screenshot of how "crooked" the fields appear in the options form.

The warning I sent you turned out to occur because of a change I had made after your own changes. So no worries there.

Cheers,
K.

Frank Steiner’s picture

This was definitely a bug in my derived form-style function! But it should be gone with the new patch version since I just reuse everything from the table view. Let me know if views_bulk_table.patch looks better!

infojunkie’s picture

Status: Active » Fixed

That's a great patch. Seems to work well so I checked it in. Keep them coming :-)

Frank Steiner’s picture

Thanks! Glad I could help!

Anonymous’s picture

Status: Fixed » Closed (fixed)

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