I am using viewfield and I am trying to create a view that filters out nodes where the embedded view is empty. Unfortunately the existing implementation of viewfield doesn't support that capability, but I could easily achieve it if I could modify the SQL generated in the views module. I'm thinking that if I could provide a fake content field that would generate the custom SQL I need and insert it in the correct place:

SELECT ..., item_count
FROM A
LEFT JOIN B ...
LEFT JOIN (select field_menu_section_nid, field_menu_special_value, count(*) as item_count from content_type_menu_item where field_menu_special_value = [arg1] and field_menu_menu_value = [arg2] group by field_menu_section_nid) node_item_section on node_item_section .field_menu_section_nid = node.nid
WHERE ...

You'll note that in my example I've got a couple args embedded in there also (just to keep things interesting, those are url arguments, not view arguments because the view arguments interfere with args getting to the embedded view in each node, and I've already hacked the token module to add those particular tokens).

Ideally what I'd like to be able to do is define a dummy field and then use that field in the filter of the view definition. Then I'd somehow specify the source for the left join, possibly just by entering the SQL directly (I've only got a handful of nodes that need this content type, and I won't be adding one too often, so it's not a big deal that it isn't the most user friendly UI.

Is this something I could do with a custom CCK field, and if so, where would I start? I've looked at the computed field and it looks like it specifically can't do what I'd like.

Thanks.

Colin