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 :)

Comments

eaton’s picture

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!

gábor hojtsy’s picture

StatusFileSize
new10.96 KB

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.

gábor hojtsy’s picture

StatusFileSize
new11.28 KB

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.

David_Rothstein’s picture

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?

eaton’s picture

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...

gábor hojtsy’s picture

StatusFileSize
new22.11 KB
new15.21 KB

@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.

gábor hojtsy’s picture

StatusFileSize
new15.2 KB

Slightly updated patch to fix notice in theme_simpleviews_edit_form().

bdunwood’s picture

I noticed that the current beta of DrupalGardens.com, which runs on Drupal 7 alpha 1 has SimpleViews installed. However I do not see a build of SimpleViews for Drupal 7 on Drupal.org. Have I missed the build somewhere?

gábor hojtsy’s picture

StatusFileSize
new15.21 KB

At drupalgardens.com we are running simpleviews patched with the patch posted here. Here is an up to date version of the patch as we use it.

BTW since there is no 7 version for Views, the array generation part of the module was not updated. Without views or a views replacement, you cannot do much with simpleviews.

BenK’s picture

Subscribing...

janusman’s picture

@gabor: what version is that patch for? It doesn't apply cleanly to 1.0 nor a DRUPAL-6--1 checkout (at least not anymore) =)

gábor hojtsy’s picture

We have this patched off of HEAD, so it is against http://drupalcode.org/viewvc/drupal/contributions/modules/simpleviews/?p...

ksenzee’s picture

StatusFileSize
new15.71 KB

It does look like all the action is on the branch, so I'm attaching a patch that should apply to a DRUPAL-6--1 checkout.

gábor hojtsy’s picture

StatusFileSize
new17.24 KB

Updated patch which also includes a fix for #697778: Conform admin table formatting to D6 standards, because D7 needs a different approach compared to D6.

gábor hojtsy’s picture

StatusFileSize
new17.19 KB

Wups, missed to include the & with the form rendering that is obviously required to get the form render info fed back to the variable.

EvanDonovan’s picture

Very cool..subscribing.

gábor hojtsy’s picture

@eaton: re-reading your last comment above, the code improvement around the Views code might need some more explanation.

This is a very small change compared to D6. This change basically centralizes the menu rebuilding and views cache rebuilding code into one function, instead of repeating the same sequence in 3 places. Now that centralized place also happens to be a new hook (hook_simpleviews_refresh) I thought would be a great way to let others hook into this action, but it is after all up to consideration whether we need this at all to let possibly others flourishing around Simpleviews to act in this case. I think it is a good code simplification. Once this centralization is done, you only have one line in the module file where it relies on views module being there, and that is the calling of views_invalidate_cache(). If you re-formulate that as module_invoke('views', 'invalidate_cache'), views becomes an optional dependency. I don't think using module_invoke is a performance problem here, since this code is only used on administrative pages (when a node type is edited and when a simpleview is saved or deleted respectively).

Maybe this helps to shed some light on the underlying ideas. I think it is fantastic that this module can be made to not require views with a 1 line change.

bdunwood’s picture

sub

yareckon’s picture

+

adellefrank’s picture

Subscribing.

gábor hojtsy’s picture

StatusFileSize
new17.69 KB

Turns out that the foreach code in the theme function caused lots of warnings when you visited the simpleviews admin interface. Here is an updated patch that fixes that.

davidneedham’s picture

I tried applying the patch from #21 to the latest DEV release, but there was an error:

patching file simpleviews.css
patching file simpleviews.info
Hunk #1 FAILED at 1.
1 out of 1 hunk FAILED -- saving rejects to file simpleviews.info.rej
patching file simpleviews.install
patching file simpleviews.js
patching file simpleviews.module
patching file simpleviews.pages.inc
patching file simpleviews.views_default.inc

Here's the simpleviews.info.rej:

***************
*** 1,6 ****
  ; $Id: simpleviews.info,v 1.3.2.1 2009/09/17 22:03:44 eaton Exp $
  name = SimpleViews
  description = An easy-to-use tool for bulding content listing pages.
- dependencies[] = views
- core = 6.x
- package = Views--- 1,8 ----
  ; $Id: simpleviews.info,v 1.3.2.1 2009/09/17 22:03:44 eaton Exp $
  name = SimpleViews
  description = An easy-to-use tool for bulding content listing pages.
+ core = 7.x
+ files[] = simpleviews.module
+ files[] = simpleviews.install
+ files[] = simpleviews.pages.inc
+ files[] = simpleviews.views_default.inc

It seemed pretty straightforward, so I tried patching simpleviews.info manually:

; $Id: simpleviews.info,v 1.3.2.1 2009/09/17 22:03:44 eaton Exp $
name = SimpleViews
description = An easy-to-use tool for bulding content listing pages.
core = 7.x
version = "6.x-1.x-dev"
project = "simpleviews"
datestamp = "1278835678"
files[] = simpleviews.module
files[] = simpleviews.install
files[] = simpleviews.pages.inc
files[] = simpleviews.views_default.inc

I tried adding a simpleview and got an error involving an invalid argument in common.inc (sorry I don't remember it and I can't recreate it). I created a very simple simpleview showing only a particular content type in teaser view and set the path to 'test'. If I go to /test, I get a page not found. I tried creating another simpleview and I don't get the error, but I still end up with page not found.

In an attempt to further troubleshoot I installed views (and ctools) and tried again (disabled and re-enabled simpleviews, created a new simpleview, etc) with the same results. I looked for the simpleview in the list of views, but it doesn't show up.

Anything I can do to fix this or help make it work for others?

gábor hojtsy’s picture

The patch implement a port of the admin functionality of simpleviews itself, and does not concern the views integration. We use this port in Drupal Gardens with a custom purpose built backend module that can generate pages with the simple criteria supported by simpleviews. The views integration part still needs to be ported, so the patch is not 100% complete.

We are currently working on a simplified user interface for views itself (to be built into views), so we don't currently have long term plans with simpleviews module. Our repository for that work is at https://github.com/ksenzee/views3ui

Ps. looking at this info file hunk, the listing of those files is not anymore necessary with Drupal 7 as it is today

yareckon’s picture

Gabor,

Could you share some of the design docs or specs for this effort you mentioned? Or is there a drupal issue thread where this work is taking place? Would be helpful to know how this is relevant to other folks's needs for a simplified views interface.

gábor hojtsy’s picture

It is in the views queue among other places: http://drupal.org/project/issues/views?text=redesign

eaton’s picture

We are currently working on a simplified user interface for views itself (to be built into views), so we don't currently have long term plans with simpleviews module. Our repository for that work is at https://github.com/ksenzee/views3ui

Now that I'm back into the swing of working with my contrib modules, and Views has been ported, I'm going to be able to give this another pass as well. I think over the long haul it'll still be a nice compliment to the work you guys are now doing on an improved Views interface. Thanks for the update!

mcaudy’s picture

Hasn't Simpleviews already been ported to D7 in Drupal Gardens?

There is a UI page that looks very similar to Gabor's original screenshot at the top of this page.

Also, there is a "Simple Views" link on the Structure overlay, and you can add a new view at:

http://username.drupalgardens.com/admin/structure/simpleviews/add

So, isn't this a duplication of effort?

Or, is Acquia not making their port available as a contrib module?

David_Rothstein’s picture

@mcaudy, there is no duplication of effort - this is the effort :) The code that was written for Drupal Gardens is what you're seeing posted in this issue.

If you're actually asking about the backend query builder (rather than the SimpleViews UI), you might want to read Gábor's post at http://acquia.com/blog/simpleviews-drupal-7-how-we-did-it :

I believe that there is no point in publishing our current backend module on drupal.org given its interim nature, but that does not make it closed source or unreleased. Any Gardens site that is exported will include a copy of this module, and it is released under the GPL.

If you believe there's value in having it be a module on drupal.org and are interested in maintaining it, feel free to post it as such. But the custom query builder was written to fill a short term need, and it's not likely to be very useful in the long term compared to the Views backend itself.

eaton’s picture

So, isn't this a duplication of effort?

Or, is Acquia not making their port available as a contrib module?

Early on Gabor offered the alternate query backend as a feature for SimpleViews here on d.o. If there's a fault to be found that it isn't part of the module it's with me, not Gabor or Acquia. ;-) The reasons for not including it are twofold. First, SimpleViews was written as a simplified front end to common Views functionality, start-to-finish. It piggybacks on the work Views does not just in query generation but also in theming and presentation.

SimpleViews is also limited in that it only exposes things that are relatively easy to do with Views -- I believe that if we're interested in providing a turnkey 'make simple lists of things without customizing them' module, it's better to build it on its own rather than piggybacking on the Views-oriented codebase of SimpleViews. Acquia is now focusing on improving the full-featured Views UI, and is putting a lot of resources into that in conjunction with Earl Miles. I think everybody wins in that situation.

gábor hojtsy’s picture

Well, I never intended to publish the simpleviews tailored backend on drupal.org neither part of simpleviews, nor outside of it. I merely abstracted very minimal parts of the simpleviews module in the port to be able to work without views being present. The simpleviews UI itself has no requirement in views, it just clears views caches, that is all it talks to the view API. Otherwise it exports Views structured arrays, which does not make views required. All-in-all, we needed to have a quick solution when Views was still a big work in progress, so we went with a KISS solution, and now we are investing in Views itself.

andypost’s picture

I think simpleviews is a good module for small sites that does not require Views module. So custom (probably exportable) query builder is enough for core's entity_query()

Suppose this module will not have Views as dependency

EvanDonovan’s picture

Is there a reason this never got committed as at least an initial 7.x branch?

davidneedham’s picture

@EvanDonovan Yes. Mostly because Views 3 already has a more robust version of Simpleviews out of the box.

https://img.skitch.com/20110619-drcbg2w4hsxxnf1fg2974xf668.jpg

Basically, there's no reason to use SimpleViews anymore because Views is better now.

ksenzee’s picture

StatusFileSize
new16.14 KB

Posting an updated patch that should apply now that we're on git. Not sure if this is still useful to anyone, but here it is in case.

markwk’s picture

Is there an actual module download for this? A github repo? I teach Drupal to Chinese students and we start with Drupal Gardens sites before transitioning to working directly on local installations of Drupal 7. Love to include this simple module for continuity.

EvanDonovan’s picture

From my understanding, Drupal Gardens no longer uses SimpleViews, since most of the UI improvements were incorporated into the latest version of Views 3.

markwk’s picture

Drupal Gardens comes with Views now but it initially installs with Simple Views.

drupalninja99’s picture

That's a good point.