0

I have a simple D7 view that lists all usernames and a couple of associated fields (business name, contact name) in table format. It has exposed filters on those fields, and about 200 users to list, sorted by creation date.

In Page View, this works perfectly as expected : I can page through a list of active users, and filter them.

However, when I try to embed the same view as a block, it displays only 6 results and no pager or exposed fields.

I've changed the pager ID - didn't help. I changed the pager ID on the other block shown with this one, too. I have no contextual filters or relationships set up. I tried changing to 'show all results' without a pager - still just those six results.

Any thoughts on where to start looking to fix this?

ETA I checked the queries being run, and as suggested, they turn out to be different in page view to block view.

This is my page view query:

SELECT users.name AS users_name, users.uid AS uid, users.status AS users_status,
 users.created AS users_created, 'user' 
AS field_data_field_business_name_user_entity_type
FROM 
{users} users
WHERE (( (users.status <> '0') ))
ORDER BY users_created DESC
LIMIT 30 OFFSET 0

But my block view query is different, all the exposed filters are applied, and I can't change them:

SELECT users.name AS users_name, users.uid AS uid, users.status AS users_status,
users.created AS users_created, 'user' 
AS field_data_field_business_name_user_entity_type
FROM 
{users} users
LEFT JOIN {field_data_field_business_name} field_data_field_business_name 
ON users.uid = field_data_field_business_name.entity_id AND 
(field_data_field_business_name.entity_type = 'user' AND
 field_data_field_business_name.deleted = '0')
LEFT JOIN {field_data_field_contact_name} field_data_field_contact_name 
ON users.uid = field_data_field_contact_name.entity_id 
AND (field_data_field_contact_name.entity_type = 'user' 
AND field_data_field_contact_name.deleted = '0')
WHERE (( (users.status <> '0') AND
(field_data_field_business_name.field_business_name_value LIKE '%%' ESCAPE '\\') 
AND (field_data_field_contact_name.field_contact_name_value LIKE '%%' ESCAPE '\\') ))
ORDER BY users_created DESC
LIMIT 30 OFFSET 0
0

2 Answers 2

0

A good way to start understanding what happens is to turn on the Show the SQL query option in the basic view settings under admin/structure/views/settings. You can then copy-paste the generated query into your database application and check if the query catches all expected results. If yes, then the problem most probably happens during the rendering of the results, maybe a custom views block template (check the theme overrides for the views display)? If no, then there is probably something wrong with the query itself, which could be either some kind of filtering, or maybe a contrib module that alters the query from code.

1
  • Thanks - that helped, but I'm still a little confused! I had assumed that it was not the MySQL query, because I thought that the query would be the same in Page view as it was in block view, but this is not the case, and I'm not sure how to change the query only in Block View. I'll paste my two queries into the original question.
    – Victoria
    Feb 27, 2014 at 15:56
0

AHA! Thanks to berliner kindly pointing out that I should check whether the two queries were different, I've got it.

In block view, my exposed filters were being applied with no option to enter a value.

I hadn't realised that the exposed filters are hidden in block view unless Ajax is turned on, but that now makes total sense. To fix this, I just had to turn on AJAX in the view, (Other-> Use Ajax -> Yes)

Just leaving this as an answer in case someone else needs it.

Your Answer

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

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