4

I've already figured out how to link views to content language by the Content: Language filter. I know that I can create a second view to use as the No Results fallback and use the Global: View area to feed the other in. But to do this I have to:

  • pollute my site's blocks with Localized and Unlocalized duplicates and hope the client understands that they should only enable the Localized block.

  • make sure to maintain a duplicate of the original with only the Content: Language filter changed.

  • tolerate a full second set of queries to generate the block? Some blocks are ordered by random, so they can't really be cached well.

Isn't there a better way to do this?

Also, I know I can use the rearrange feature on the languages to set up conditions like:

Content: Language (In user's current language) OR
Content: Language (In default site language)

But the issue is that then these languages are mixed. I need the default site language to appear only when there are no nodes in the current user's language.

0

Check out http://www.webomelette.com/drupal-views-pre-render-alter-display, u should be able to use hook_views_pre_render() in a custom module and check your result set before rendering.

In the case of no results, change language to sites default in the view object, although im not sure that this hook will trigger your new query to run and bring the default lang contents, but its a start!

http://drupalcontrib.org/api/drupal/contributions%21views%21views.api.php/7

  • 1
    Well, looks like I'll have to use this hook with an OR condition like I mentioned. This'll let me filter results as I want, in theory. I'll comment again to say how it goes. – Robert K Mar 19 '14 at 21:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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