Hello, I had get this error working with
Shadowbox 7.x-4.0-beta4+6-dev ( in 4 modules )
Display suite 7.x-1.5
Fieldgroup 7.x-2.x-dev
File entity 7.x-1.0
Media 7.x-1.0
Media Browser Plus 7.x-1.0-beta3
Media: YouTube 7.x-1.0-beta3
I had searced but none reference to this issue, my languaje is spanish sorry for my bad use of english.
When I add a image or video, then save the form, and get this in the window:
Notice: Undefined property: stdClass::$nid en file_shadowbox_field_formatter_view() (línea 211 de /var/www/vhosts/misite.es/httpdocs/sites/all/modules/shadowbox/file_shadowbox/file_shadowbox.module).
But I can see all render ok in the window, and ig get running open as well.
Thanks.
:) Magnific work.
Comments
Comment #1
5n00py commentedHi! I have same issue with this PHP notice:
I make some code review and found this mistake:
Shadowbox have setting for node related gallery, so gallery have id like this: nid-10.
Good, BUT!!!
I have image field attached to commerce product entity. This entity referenced by product-display node type.
$gallery_id = "nid-{$entity->nid}";In my case there is not nid property in entity.
Comment #2
manfer commentedThe only thing by now I can think to avoid that notice is to just check on the code that nid exists and if not -as on those entities you refer to- then I don't group the entities into a gallery. To solve the problem on your fields is as easy as not using the 'gallery node' nor the 'gallery field node' on the shadowbox formatter configuration of your field if your entities are not nodes.
If you need for some reason to add several images to an entity which is not a node and you need to group the images as a gallery just use only one field and on that field allow multiple values (multiple images) and then in the shadowbox formatter use 'gallery field page' which groups all the images on a field as a gallery.
Comment #3
5n00py commented#2
You're right!
But we can group images to galleries using id's like:
If this is useful, I can create a patch to do this thing.
Comment #4
manfer commentedThe problem is that not all entity types has ids either if I'm not wrong. At least for what I read there is even a module trying to enhance the core entity API and one that tries to provide a unique entity identifier. If there were a unique identifier for all entities it would be better but sadly seems there isn't.
Anyway what I can do is use id when there is no nid, and if there is no nid, nor id, then don't do the grouping (gallery=""). Unless or until someone finds better solution.
I would need and identifier on entity, not entity_type. Could you find out if your products entities have any kind of identifier? Should be $entity->id and not $entity_type->id.
Or what about the created timestamp or the revision timestamp. Does all entities have one? This should be unique so if all entities have one would be great candidate.
Comment #5
5n00py commentedentity_type or bundle name prefix can help to make unique ids.
If we have node with id 3 and taxonomy term also with id 3 we can have gallery ids like:
node-3 and term-3.
This is unique.
Also you can look to field table in database , it have next columns:
entity_type
bundle
entity_id
field_images_fid
...
Comment #6
manfer commentedI think I found which is the correct way to do this. Here is the provisional patch and maybe before commiting I change the label from "gallery node" to "gallery entity"
Comment #7
5n00py commentedThis patch fix notices and handle non-node galleries like term or any other entity.
I already test it in different settings.
Comment #8
manfer commentedLol exactly same time patch. Well at least I see is exactly the same way to do it so probably I can consider it has been reviewed. :)
In my patch I actually do the necessary changes to file_shadowbox too.
So now I think I'm going to change the label and push the patch.
Regards.
Comment #9
manfer commentedSo here is the new patch that now includes the change of labels from "gallery node" to "gallery entity" and from "gallery field node" to "gallery field entity"
As gallery field node had same issue this new patch includes the changes in that case too.
Done both in image shadowbox and in file shadowbox modules.
I think now it is prepared to be pushed.
Comment #10
manfer commentedStill some labels where not updated. New patch to solve that.
Comment #11
manfer commentedComment #12
5n00py commentedMore friendly ids.
Applicable to the latest changes.
P.S.: Its good idea to get some time for review patches by other people :)
Comment #13
manfer commentedPushed too. Thanks.
Comment #14
5n00py commentedThanks!