Initial port to Drupal 7

Gábor Hojtsy - October 27, 2009 - 14:13
Project:SimpleViews
Version:6.x-1.x-dev
Component:Code
Category:task
Priority:normal
Assigned:Unassigned
Status:needs review
Description

I took simpleviews and ported it to Drupal 7 (without actually considering a released Views backend). Because we do not have Views yet, I commented out the views dependency and the direct views cache flush calls.

Update changes include:
- css: only apply 18em width to text input; this was giving the checkboxes a 18em width, which looked very odd
- info: list files in files[]
- install: hook_install and hook_uninstall are not needed due to automated schema install/uninstall
- js: apply D7 jQuery wrapping; uncomment preview img placeholder due to how it broke the layout
- module:
- moved to admin/structure where views is also expected to be
- associative result fetching converted to DBTNG (at 2 places)
- only specify #tree TRUE in the listing form if there are actual values (specifying it at all times seemed to cause problems in rendering)
- #type markup key changed to #markup, not #value
- drupal_render_children() should be used when we are already in rendering the same element, but need the children rendered
- node_get_types('names') -> node_type_get_names() API change

This makes adding, saving, editing, deleting simpleviews work like a charm. Seems like there might be small bugs around how the last two checkboxes are saved / handled, I'm still to look into that.

Listing of some sample simpleviews I created:

Editing my articles view:

I hope this helps :)

AttachmentSize
port-simpleviews-to-d7.patch10.86 KB
SimpleViewsD7.png26.02 KB
EditSimpleView.png38.64 KB

#1

eaton - October 27, 2009 - 23:06

Absolutely. KarenS and I will probably put togeter a D7 branch after a couple of new D6 changes land (including a CCK field for SimpleViews) then open the D7 branch starting with this patch. Thank you!

#2

Gábor Hojtsy - October 29, 2009 - 12:37

Simpleviews just makes a perfect job in being independent of views in terms of data storage and UI. Since we can start using simpleviews with an extremely simple query builder while Views is not yet there, I've decided to remove the dependency line in the .info file and abstract the views and menu cache clearing into a hook which other modules can hook into. That theoretically allows a very simple query builder to support simpleviews without views actually being there.

I've looked up the only remaining views function which is supposed to be invoked, called views_flush_caches(). That function says is a hook_flush_caches() implementation and returns an array of table names. So just invoking that function like simpleviews does would not have any results whatsoever. I'm wondering if you meant regular views cache flushing like at the other three places.

AttachmentSize
simpleviews-d7-viewsless.patch 10.96 KB

#3

Gábor Hojtsy - October 29, 2009 - 16:39

I've experienced some funky behavior before and looks like it was just a simple copy-paste bug (applied to D6 of simpleviews). You use the 'rss' key of the simpleview to default the sidebar widget checkbox. Not surprising it was behaving crazy. Fix included in this updated patch.

AttachmentSize
simpleviews-d7-viewsless.patch 11.28 KB

#4

David_Rothstein - November 2, 2009 - 23:02

Here's an updated patch that chases the latest D7 codebase. Changes (as can be seen from the attached interdiff file):

  • Now using hook_permission() correctly.
  • Updated for recent changes to hook_theme() and theme() function calls.
  • Updated to use the D7 database API correctly, without the backwards-compatibility layer.
  • Updated for recent changes to the form API which now require functions that define forms to take $form as their first parameter.
  • A couple minor D7 code style fixes.

Not done in this patch, but worth thinking about:

  • It seems like the "Add view" link should probably be moved from a MENU_LOCAL_TASK to a MENU_LOCAL_ACTION to conform to D7 guidelines?

By the way... I noticed that all the patches so far in this issue (including mine) have been rolled against HEAD - but it looks like the latest code for this module is actually on the DRUPAL-6--1 branch. Is that the code from which the D7 port should actually start?

AttachmentSize
simpleviews-d7-viewsless-615882-4.patch 15.13 KB
interdiff-615882-3-4.txt 5.47 KB

#5

eaton - November 2, 2009 - 23:56

The DRUPAL-6--1 branch is where most of the minor bug-fix work has been going on, but I can check to see if they've gotten too badly out of sync. Now that Views 7.x-3.x is in CVS, I'm not sure about the value of putting in hooks for alternate query builders. I'd much rather focus on using SimpleViews to provide clean, no-questions-asked ways of exposing Views functionality, as opposed to creating another meta-layer with its own way of describing certain abstract problems...

#6

Gábor Hojtsy - November 4, 2009 - 10:24

@David_Rothstein: Attached patch now implements your suggestion of using the standard action links in D7 to conform to current UI guidelines. No other changes.

@eaton: I'm seeing how a swappable UI is good but a swappable backend might not be preferred. I'd say it has merit on the level of simplicity simplenewssimpleviews represents, and it does not require anything else but what we have in the patch already.

AttachmentSize
simpleviews-d7-viewsless-615882-6.patch 15.21 KB
SimpleViewsAction.png 22.11 KB

#7

Gábor Hojtsy - November 9, 2009 - 10:47

Slightly updated patch to fix notice in theme_simpleviews_edit_form().

AttachmentSize
simpleviews-d7-viewsless-615882-7.patch 15.2 KB
 
 

Drupal is a registered trademark of Dries Buytaert.