How do I alter the view which are available for users to put in their nodes? I don't want absolutely every view on my site at my users' disposal.

Comments

jamesJonas’s picture

Here is a quick hack, not a long term solution.
(1) modify the viewfield.module
(2) put the word 'Public_' in front of the views you wish to make available.

Long Term:
(1) Create a variable for the Prefix that can be edited by the administrator.
(2) Create a checkbox for including or excluding the default views.

My Use:
User creates a node, which contains a view. This view then recieves specific node parameters via arguments, directly to the view (php), or perhaps via tokens inside the arguments (work in progress). The argument section, which I would customize, would be hidden from the user via the FormFilter.module, thus creating a simple user interface.

<?php
/**
 * Prepare a list of views for selection.
 */
function _viewfield_potential_references($field) {
  $options = array();
	
	// add a null option for non-required fields
	if (!$field['required'] && !$field['multiple']) {
			$options[0] = '<' . t('None') . '>';
	}


  include_once(drupal_get_path('module', 'views') . '/views_cache.inc');
  $default_views = _views_get_default_views();
// filter the list of views using a like operator. Put the word 'Public_' before public views
// Before    $res = db_query("SELECT name FROM {view_view} ORDER BY name");
// Direct Query Test:  SELECT name FROM view_view where name like 'Public_%' ORDER BY name;
  $res = db_query("SELECT name FROM {view_view} where name like 'Public_%' ORDER BY name");
  while ($view = db_fetch_object($res)) {
    $options[$view->name] = $view->name; 
  }
  
// drop the default views
/*
  if(is_array($default_views)) {
    foreach($default_views as $key => $view) {
      $options[$key] = $view->name;
    }
  }
*/
  return $options;
}

?>
darren oh’s picture

Status: Active » Closed (duplicate)

Duplicate of issue 138028.