Today I had the idea, that the views.module itself could provide a function any contrib module (and views itself) can use to select a view/view display in a FAPI element - like select or checkboxes.

I created a patch to add this function. It contains:

* views_only: to return only views, else it returns [view name]:[display id] as key
* filter: with keywords 'all', 'enabled' and 'disabled' views can be filtered according to the three existing functions
* exclude_view: view object or string to exclude the view from the options array
* optgroup: return the array as nested options array, so it would be rendered as optgrouped select

CommentFileSizeAuthor
views_get_views_as_options.patch4.25 KBderhasi

Comments

dawehner’s picture

Version: 7.x-3.x-dev » 6.x-3.x-dev
Status: Needs review » Patch (to be ported)

Thanks for writing the patch. Looks fine and really flexible.

Commited to 7.x-3.x.

In general this seems to be valuable for 6.x-3.x as well.

mstrelan’s picture

This breaks #1172714: Use the Global: View area to reference another display of the same view.

+ $options = views_get_views_as_options(FALSE, 'all', $this->view);

should be

+ $options = views_get_views_as_options(FALSE, 'all');

mustanggb’s picture

Issue summary: View changes
Status: Patch (to be ported) » Closed (won't fix)