Closed (fixed)
Project:
Country code
Version:
6.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Reporter:
Created:
16 Sep 2008 at 22:14 UTC
Updated:
14 Jul 2012 at 23:21 UTC
Approach:
country_code_views_query_substitutions() enables the use of a '***COUNTRY_CODE***' query substitution.
hook_views_data_alter() to add fields like $data['users']['uid_current'] in users.views.inc in views module.
TBD: what table.fields should this filtering be enabled for? Where is it possible to filter by country code? Possibilities: http://drupal.org/project/cck_address, http://drupal.org/project/location.
Comments
Comment #1
recidive commentedAdded basic views filter allowing to filter by country, including 'global' and user current country.
Comment #2
recidive commentedViews filter should also check for node in the same translation set, e.g. if there are en and en-CA versions of the same node, only en-CA should be displayed for Canada.
Comment #3
nedjoYes. When filtering, a view should show content that are either (a) for the current language (en) and no country-language translation (en-CA) exists or (b) for the current country-language (en-CA).
Comment #4
nedjoI'm working on this, through query substitutions.
Comment #5
nedjoI've implemented views query substitutions for:
a. '***COUNTRY_CODE_COUNTRY***' - the current country, e.g., 'ca' for Canada
b. '***COUNTRY_CODE_COUNTRY_language***' - the current language for the current country, e.g. 'en-CA' for Canadian English.
And I've written an initial filter, that works like this:
1. Provide list of countries to filter by, including the current country.
2. When running filter, add where condition for the countries fed in. For example, if 'en and 'us' are fed in, content in any language ending in '-CA' or '-US' will be returned.
This is maybe marginally useful for some admin purposes, but doesn't meet the main need.
We need a second filter to cover off the main need which is e.g.:
When browsing from Canada and the current language is English, match all content that is either 'en-CA' OR is 'en' and there is no 'en-CA' translation.
For this, we need to have a join on node.tnid. The query needs to work out to:
Or, with query substitutions fed in:
Not sure yet how to build this filter.
Comment #6
nedjoI've added and commented up a stub filter handler.
Comment #7
nedjoTalked with merlinofchaos. Looked at the possibility of doing this through a relationship, but since we're trying to filter out rather than work with the relationship data, it makes sense as a straight filter. From merlinofchaos:
Comment #8
nedjoCommitted a filter. Seems to be working. Needs testing.
Comment #9
nedjoSuccessfully tested.
Comment #10
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.