View 2 integration

ekes - July 12, 2009 - 14:20
Project:Active Translation
Version:6.x-1.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:needs review
Description

Just basic views 2 integration.

The attached patch (built against HEAD in the module directory - sorry - so you'll need to be in it to run patch -p0 so it creates views directory correctly):

  • stops active_translation.module hook_db_rewrite_sql from altering a views query
  • adds an active translation relationship to views in the i18n category. Using this relationship and making it Required operates as active_translation normally.
  • adds a (default disabled) example of this relationship in use as the view at_frontpage

This not only has the bonus of being able to switch on and off active translation with views, it makes views aware of the query thus making it possible for it to cache them.

AttachmentSize
active_translation.views-20090712.patch7.06 KB

#1

drewish - July 12, 2009 - 16:09

this looks good over all some of the comments need to be proper sentences with capital letter and periods though. i think the view should probably be tagged with the module name.

though it brings up a bigger problem with the module, it's using ***CURRENT_LANGUAGE*** as a field name. the problem being that language codes conflict with database reserved works. i'm sure using Icelandic you'll get a column named "is". i won't let fixing that block the views support but it just reminded me of it.

#2

ekes - July 12, 2009 - 16:15

The views replacement is just done by a str_replace so it would easy enough to move it to tnid_is (as tnid_***CURRENT_LANGUAGE***) or what ever if the column names were to change.

#3

ekes - July 12, 2009 - 17:30

Talking about c&p errors - corrected patch

AttachmentSize
active_translation.views-20090712.patch 7.07 KB

#4

nwe_44 - September 21, 2009 - 09:48

Has this patch been implemented in the dev release? I'm getting error messages on a multilingual site on a page using a view with a node reference argument. The multilingual options on the node reference argument are turned on. When they are turned off, the error messages disappear, but translations of referenced content are no longer taken in to account.

The error message is as follows

user warning: Unknown column 'n.nid' in 'on clause' query: SELECT node2.nid, node2.vid, node2.title FROM node node INNER JOIN node node2 on node2.tnid = node.tnid INNER JOIN active_translation ON n.nid = active_translation.en WHERE 1 = 1 AND ( node.nid IN (145) AND node.tnid > 0 ) in /Applications/MAMP/htdocs/vem/sites/all/modules/contrib/nodereferrer/views/nodereferrer.views.inc on line 99.

#5

ekes - September 25, 2009 - 10:20

The patch isn't in the module no. Any multilingual options therefore I guess are from i18n which is going to be a strange play. Why not try the patch and not the i18n options ;)

#6

nwe_44 - October 2, 2009 - 16:26

Fantastic, patch worked a treat for me. Thanks very much.

 
 

Drupal is a registered trademark of Dries Buytaert.