Reputation: 12194
I'm building an Address Book view based on a simple CCK that I built.
I need to pass the initial letter as argument to the view in order to show only the elements starting with the received letter. How can I do it using Drupal Views? I've searched in arguments but cannot find a way to get substring support but only node/user references or CCK fields.
Upvotes: 0
Views: 356
Reputation: 31
If you use this:
$view = views_get_view('masvisitados');
$view->execute();
print_r( $view->render() );
It will render with the markup, but If you just want the data (like me), you can try this:
$view = views_get_view('masvisitados');
$view->preview('Mas visitados', 4);
$view = $view->result;
print_r( $view );
It returns an array.
Upvotes: 3
Reputation: 1424
...
$view->set_exposed_input( array('field1' => data1, 'field2' => 'some data') );
...
Upvotes: 1
Reputation: 5642
That's exactly what a "glossary view" does. Navigate to /admin/build/views on your site. If the default view called "glossary" is disabled, enable it. You can now edit/inspect/try it to see how it works. The key is in the 'Node: Title' argument, where the "glossary mode" checkbox is selected. For your address book, you can duplicate it and add a filter on the desired node type.
Upvotes: 2