Content selection: request about mixed mode.
| Project: | Internationalization |
| Version: | HEAD |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Hi,
currently mixed mode only supports selecting nodes in Current and Default languages. Isn't this limiting?
Could this be improved to select also nodes in other languages (like mode 'off' does), still avoiding duplicates when a node has several translations?
I am designing a multi-lingual blog, which could support many languages, but only some nodes will have translations (either in only some or all defined languages).
Ideally on front page I would like to show content also in languages other than current or default (which should not be special from a user point of view) so the rules I would like to use to display content on front page would be as follow:
- Iterate though all nodes to display on front-page (as per Content Selection = off)
- If a node has a translation in current language show this one and discard other translations
- If a node has not a translation in current language but it has one in default language, use the latter and discard other translations (not sure about that, IMHO users should not care what the default language is)
- If a node has translations but neither in current (or default language), pick the first translation and discard the others
- If a node has only one translation, just display it
- If a node is language neutral, display it.
You query gurus can express that declaratively and more simplified, but I showed it this way hoping to show my idea more clearly.
I have still to research how to do what I am asking with Views, but the description above could well match a naive definition of "mixed mode" that's why I am posting here first. Any comments?
Regards,
Antonio

#1
Hi,
it looks like this kind of request is quite popular :) I found similar ones #203798: Preferred language option and #78973: List translated nodes without duplicates, in particular, the latter asks pretty much what I am also asking.
I ported the patch from #78973: List translated nodes without duplicates to i18n-6.x-1.0, which I am attaching here.
It works for me on frontpage, but I would like to hear what do you think about it.
Waiting for comments...
Regards,
Antonio
#2
mmh, maybe we can use
UNIQUE(tnid)after ordering the nodes instead of using a subquery?Regards,
Antonio
#3
Well, as dereine pointed out in #434308: Filter duplicate translations, the
UNIQUEway can't work because nodes without translations are all in the same translation group withtnid=0.So, the query I am searching for should really be this one:
SELECT *FROM node AS n1
WHERE (n1.promote <> 0) AND (n1.status <> 0) AND (
tnid IS NULL OR tnid=0 OR nid=(
SELECT nid FROM node AS n2
WHERE n2.tnid=n1.tnid
ORDER BY
CASE n2.language
WHEN @current_language THEN 1
WHEN @default_language THEN 2
ELSE 1000
END
LIMIT 1
)
)
ORDER BY n1.sticky DESC, n1.created DESC;
Which I find more readable than the old one I copied from mardy78.
I attach here an updated patch, please let me know if you find it suitable for inclusion, in that case we could find a better name than "mixed_single" which I don't like too much.
Regards,
Antonio
#4
Ok, the Active Translation module does basically what I am looking for, and I also found the solution for Views in the Select Translation module.
I am leaving the issue open and changing the target to HEAD, maybe you can add this content selection mode to D7 so an external module would not be needed anymore for a such fairly requested feature.
Thanks,
Antonio
#5
Personally I'd just mark this as fixed and suggest people use the Active Translation and Select Translation modules but I'll leave that up to the i18n maintainers.
#6
Waiting for a solution for this too... I need to select in the views, content in the user language, and if itsn't available , then default language.
#7
jarizaro2, well you can always grab active translation and then try out this patch #516918: View 2 integration
#8
If you use Views the Select Translation module should be ok for you. It solved the issue perfectly for me and without using an additional table in the DataBase as Active Translation does.
#9
drewish> Personally I'd just mark this as fixed and suggest people use the Active Translation and Select Translation modules but I'll leave that up to the i18n maintainers.
Right, I think it's the best option.
Also I'm working on some more flexible query rewriting options so this should be a pre-requiste for any other related improvement #364001: Improve query rewriting and content selection: options, parameters, fine tuning
#10
Automatically closed -- issue fixed for 2 weeks with no activity.