How to display the total count of results of a view ?

vstmusic - August 3, 2009 - 09:53
Project:Views Custom Field
Version:6.x-1.0
Component:Code
Category:support request
Priority:normal
Assigned:Unassigned
Status:active
Description

Hi,

(sorry for my bad english)

I want to create a view in wich there is a column that display for each node the results of another view (the node Id of each node of the first view is the argument of the second view).

Do you undersand me ?

For example :

View 1 : the titles of nodes of a specific content type are displayed.

View 2 : This view is shown in a block in each nodes of the specific content type. The node id is the argument of this view.

I want to display the count of results of views 2 in view 1. Is it possible ?

In the view 1, I have created a custom field php, but I don't understand what code I must write.

Can you help me ?

Thanks !

#1

vstmusic - August 13, 2009 - 18:54

Solution :

<?php
$node_id
= $data->node_vid;
$view_args = array($node_id);
$display_id = 'Bloc';
$view = views_get_view('name_of_the_view');
    if (!empty(
$view)) {
    
$view->execute_display($display_id , $view_args);
}
$count = count($view->result);

print
$count;
print
" fois";
?>

 
 

Drupal is a registered trademark of Dries Buytaert.