I have a question about Drupal 7 and Views. Let's assume that I have views where I extract 2 articles ordered by post date. I want to extract only title and trimmed introduction (trim configured in field settings in view)
Now I would like to extract this data programmatically without HTML markup. So the result will be similar to this:
array(
0 => array(
'title' => 'Lorem ipsum',
'introduction' => 'Lorem ipsum dolar solor...'
),
1 => array(
'title' => 'Lorem ipsum2',
'introduction' => 'Lorem ipsum2 dolar solor...'
)
)
Is it possible to extract such information from views? I tried to do something like this:
$view = views_get_view('view_name');
$view->set_display('display_id');
$view->execute();
$data = $view->result;
But $data
contain two elements with full nodes (all additional fields that I don't want to grab from database)
In addition for instance introduction is grabbed fully (must be trimmed somewhere in PHP).
Is it possible to do something like this:
$view->applyFilters(); //Like trim etc
$data = $view->getResults(); //return title + trimmed introduction but without HTML markup
Do You have any tips how to solve this problem? Is it possible for instance to pass template that will be rendered (where I could display only raw result without any HTML tags) or something?
Any help would be appreciated:)
$view->preview()
it will generate something like this:<div class="views-field views-field-field-introduction"><div class="field-content">Lorem ipsum...</div></div>
I don't want the outer html i just want Lorem ipsum...