2

I would like to have "select" with some views so I can chosse one of them and the submit the selection to display the result. something like this:

Block test

And this is close to what I want :

  $form['title'] = array(
'#type' => 'select',
'#title' => t('Display amount'),
//'#required' => TRUE,
'#options' => drupal_map_assoc(array('1','2', '3', '4', '5', '6', '7', '8')),
'#default_value' => 5,
'#ajax' => array(
    'callback' => 'form_ajax_submit',
    'wrapper' => 'contenido-div',
    'method' => 'replace',
    'effect' => 'fade',
   ),
    );

 $form['content'] = array(
'#type' => 'select',
'#title' => t('Content'),
'#options' => array(node_type_get_names()),
'#ajax' => array(
    'callback' => 'form_ajax_submit',
    'wrapper' => 'contenido-div',
    'method' => 'replace',
    'effect' => 'fade',
),
);

$form['views'] = array(
'#type' => 'select',
'#title' => t('views'),
'#options' => array(),
'#ajax' => array(
    'callback' => 'form_ajax_submit',
    'wrapper' => 'contenido-div',
    'method' => 'replace',
    'effect' => 'fade',
 ),
);

Thanks

2
  • Do you need to display nodes in view with settings (display amount and content type)?
    – Eugene
    Aug 31, 2015 at 14:54
  • Yes Eugene, that is what I want !
    – Gucho Ca
    Sep 1, 2015 at 13:16

1 Answer 1

1

As Views is a CTools Export UI based module, the correct way to load all views is by using the CTools Export function: ctool_export_crud_load_all()

Example

ctools_include('export');
$views = ctools_export_crud_load_all('views_view');
$options = array();
foreach ($views as $view_id => $view) {
  $options[$view_id] = $view->human_name;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.