Hello,

I have a content type gallery.
I have also a content type A with a noderef to content type gallery.

I have a specific template for content type A.
For not showing the noderef field if no image inside the gallery, I added the following code :

$nodeGal = $node->field_galerie[0]['nid'];
$nodeGal = node_load($nodeGal);
$nbre_img_gallery = count($nodeGal->images);

And I tested $nbre_img_gallery.
Everything was OK.

Since some weeks, I make my website multilingual: French (default) and German.
Content type A must be multi, with translation.
Content type gallery is not multi, it’s easy to understand why.
There is a problem with noderef fields when translations are not 1 to 1, since a long time (since always?).

For other content types, I added a little code to make it work, and it was working well.
I tried nearly same coding in my case of content type A + gallery.

But I have a problem because my test on $nbre_img_gallery is not working when I’m on German language:
$nodeGal before node_load is OK (same id than in French) but $nbre_img_gallery is always = 0.
A dump of $nodeGal after the node_load shows images (Array, 0 elements) instead of
images (Array, 14 elements).

Do you have an idea why it indicates no image?

It can be seen here :
French: http://www.musee-des-bisses.ch/bisse/bisse-de-clavau, gallery field is just beneath the photos.
German: http://www.suonenmuseum.ch/bisse/de/bisse-de-clavau , no gallery field

CommentFileSizeAuthor
#6 incoherent images number.pdf32.73 KBsahuni

Comments

scroogie’s picture

You will have to load the original node by using the translation source nid of the translation set (tnid) instead of the nid directly. If we have enough time, we will work on translation for Node Gallery 3.1.

sahuni’s picture

Thanks scroogie. It works with tnid.

scroogie’s picture

Category: bug » support
Status: Active » Fixed

You're welcome.

sahuni’s picture

Status: Fixed » Active

Sorry, my tests were not good.
Your idea is not working. Tnid is not valuable because gallery is not multi.

When being in German language,
it’s Ok loading $node->field_galerie[0]['nid'] for a content which has not been translated,
but KO for a translated content.
My noderef field is working, but not my test which counts images inside the gallery.

The 2 examples are following. For me, I’m loading the same node of content type gallery.
So why images are 0 for gallery relative to a translated node (instead of real number) and 4 for a gallery relative to a not yet translated node with 4 images in its gallery.

Exemple with a not translated content

$nodeBisseId = $node->nid;
dpm($nodeBisseId); => 779
$nodeGal = $node->field_galerie[0]['nid'];
dpm($nodeGal); => 780
$nodeGal = node_load($nodeGal);
dpm($nodeGal);
nid (String, 3 characters ) 780
type (String, 20 characters ) node_gallery_gallery
language (String, 0 characters )
tnid (String, 1 characters ) 0
translate (String, 1 characters ) 0
vid (String, 3 characters ) 780
title (String, 12 characters ) Augstborderi
data (String, 90 characters ) a:2:{s:13:"form_build_id";s:37:"form-2669f629ba...
a:2:{s:13:"form_build_id";s:37:"form-2669f629badeb0c6146a2860c20164d9";s:7:"contact";i:1;}
path (String, 20 characters ) gallery/augstborderi
images (Array, 8 elements)



And with a translated content

$nodeBisseId = $node->nid;
dpm($nodeBisseId); => 1730 (nid of French node is 133)
$nodeGal = $node->field_galerie[0]['nid'];
dpm($nodeGal); => 134 (same as for French)
$nodeGal = node_load($nodeGal);
dpm($nodeGal);
o ... (Object) stdClass
nid (String, 3 characters ) 134
type (String, 20 characters ) node_gallery_gallery
language (String, 0 characters )
tnid (String, 1 characters ) 0
translate (String, 1 characters ) 0
vid (String, 3 characters ) 134
title (String, 5 characters ) Ayent
data (String, 587 characters ) a:3:{s:13:"form_build_id";s:37:"form-685ac6f02e...
a:3:{s:13:"form_build_id";s:37:"form-685ac6f02e7f8217dbbdde715f5edd3f";s:7:"contact";i:1;s:9:"nodewords";a:7:{s:8:"abstract";a:1:{s:5:"value";s:0:"";}s:9:"canonical";a:1:{s:5:"value";s:0:"";}s:9:"copyright";a:1:{s:5:"value";s:0:"";}s:11:"description";a:1:{s:5:"value";s:0:"";}s:8:"keywords";a:1:{s:5:"value";s:51:"bisse, musée des bisses, inventaire, médiathèque";}s:13:"revisit-after";a:1:{s:5:"value";s:1:"1";}s:6:"robots";a:2:{s:5:"value";a:6:{s:9:"noarchive";i:0;s:8:"nofollow";i:0;s:7:"noindex";i:0;s:5:"noodp";i:0;s:9:"nosnippet";i:0;s:6:"noydir";i:0;}s:11:"use_default";i:0;}}}
 path (String, 13 characters ) gallery/ayent
images (Array, 0 elements)

scroogie’s picture

Could you paste the full output of the loaded node with the same nid where once it works, and once it doesn't? It doesn't seem to make sense that, how you say, the output for the exact same node id differs.

sahuni’s picture

StatusFileSize
new32.73 KB

Look at attachment, please

sahuni’s picture

Well I don't know why I have problem with node_load($nodeGal);
But I solved my issue with selects in DB instead of node_load.
All that times lost because nodereference fields are incoherent with i18n in some cases ...

scroogie’s picture

The problem seems to be that the image nodes are not language neutral in the database. They have "language => fr". It might be a db_rewrite_sql in the i18n module that hinders the gallery in other languages from loading these nodes. This is only a speculation, though, as I didn't have enough time to investigate properly.

scroogie’s picture

Status: Active » Closed (duplicate)

I will look at this as part of i18n (hopefully for 3.1).

#656192: Multilanguage Node Gallery