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
| Comment | File | Size | Author |
|---|---|---|---|
| views_get_views_as_options.patch | 4.25 KB | derhasi |
Comments
Comment #1
dawehnerThanks 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.
Comment #2
mstrelan commentedThis 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');Comment #3
mustanggb commented