I figured this would be a breeze given the nifty node based concept of Node Gallery - but alas, ran into a show stopper in the last step of the process. This is what I did:

  1. I installed Node Gallery & Node Gallery API into a drupal 7.16 default test installation with not very many other modules running at the moment (just basics like views, chaos tools and similar)
  2. seeing Node Gallery had unsatisfied dependencies, I also installed file_entity-7.x-2.0-unstable7 and file_entity_link-7.x-1.0-alpha2 (as the latest available) and enabled them all.
  3. the default gallery relationship was created, I added a gallery instance with a few test files and then went to add a field onto the article content type.
  4. It was looking great: in the existing file types dropdown there was a lovely Entity Reference: node_gallery_ref_1 option which I selected and widgeted as a dropdown list,
  5. and left the field settings at default (Target type: Node, Entity Selection mode: Node Gallery, Node Gallery Behavior).
  6. the display I set to "rendered entity", view mode : teaser.
  7. Then I moved to a sample article I had created and selected my test gallery via the new dropdown, giving me a fine preview of the desired result: the teaser view of the associated gallery under the article content.
  8. But lo, saving this put an end to the smooth ride: the gallery reference wasn't added, instead I got this error message:

    Notice: Trying to get property of non-object in NodeGalleryBehaviorHandler->NodeGalleryRelationshipCrud() (line 84 of W:\sli\drupal\sites\all\modules\node_gallery\plugins\entityreference\behavior\NodeGalleryBehaviorHandler.class.php).
    EntityMalformedException: Missing bundle property on entity of type node_gallery_relationship. in entity_extract_ids() (line 7562 of W:\sli\drupal\includes\common.inc).

    The website encountered an unexpected error. Please try again later.

Well. Later didn't help.

So, where did I go wrong?
I'll be happy to supply any further information that could help to resolve this.

Many thanks in advance!

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

zengenuity’s picture

Are you saying you installed Node Gallery, so you got the default Gallery and Gallery Item types. Then, you added node_gallery_ref_1 to the Article content type manually from the content type manage fields interface? If so, that's not the way you're supposed to do it. You need to edit the Node Gallery Relationship Type under Configuration, Content Authoring, Node Gallery. From there, you can add more item types to a gallery relationship type. (it will take care of the reference fields for you)

Attached is a patch that will prevent the error when you add the field manually. (though, it doesn't make that way work...just prevents the fatal error)

calliandra’s picture

thanks for the quick reply, zengenuity

I tried to do as you suggested but, if I understood you rightly, this goes in a direction I don't actually want.

  • If I add "article" to the item types, I get a file upload field "Gallery Media" in the Article Edit view which then displays as a file link on the article page. (also, I can add only 1 image). If I go to my existing galleries, I get the weird option to upload an article as gallery media, which is all wrong in many ways...
  • otoh, If I add "article" to the gallery type, I get all sorts of controls and the ability to display a set of images in gallery style directly within the article. The article is even displayed on the galleries overview page (as if it were a gallery) BUT I could not find any way to select the "article-gallery" as I could do with other regular galleries via the entity reference:node_gallery_ref_1 ...
    In short, the article then acts kind of like an anonymous, fixed instance gallery in this case.

So...
maybe I need to step back and be more precise about what I do want:

  • I want articles, and I want galleries, that can each be handled separately.
  • Sometimes, an article will be supplemented by a large amount of images, which are to be stored in a separate gallery (and can, in this way, also be displayed in a slideshow on the front page, for example).
  • So what I am wanting to achieve is
    1. a mechanism by which the author of an article can choose from the existing galleries
    2. and have (basically it's just) a link to that gallery displayed on the articles page in gallery teaser format.

Doing as I described, I got exactly the Gallery selector I wanted (1.), and even the teaser display (2.), but only in preview mode.

So, if you're saying the way I did it is not meant to go well, how else can this be achieved?

Thanks again!

scroogie’s picture

I think you simply want a reference to the gallery in your article type. Try adding a seperate entity reference or any other reference implementation like node reference field to your article type.

calliandra’s picture

I went and added a new field as suggested, and this works just fine.

Playing around with the settings however, I discovered that what generated the error I first mentioned was actually not my choice of field but the setting:
Entity Selection mode: Node Gallery
This just won't work.
Using the "Simple" mode and specifying "Gallery" as the bundles to made available for selection does.

I went back and tried reusing the already available Entity Reference: node_gallery_ref_1 and set the Entity Selection mode to Simple (with optional filter by bundle).
And lo, this works just as well. hm...

This leads me to the question whether there is anything that actually speaks against using (the already existing) - Entity Reference: node_gallery_ref_1 for creating the gallery selection dropdown as opposed to creating a new reference field of its own? What is it usually meant to be used for?

And what is the Selection Mode: Node Gallery designed to be used for?

Thanks again!

zengenuity’s picture

If you change the node_gallery_ref_1 selection mode to Simple, I think you will break the gallery functionality. At the very least, you are going to break the selection handling that is usually determined by the relationship type settings. (which content types are galleries and items) Node Gallery Selection Mode allows NG to override some defaults in Entity Gallery and handle selection and saving behavior.

For what you want to achieve, you definitely want to do what @scroogie said in #3.

zengenuity’s picture

Err...EntityReference I meant, not Entity Gallery.

zengenuity’s picture

Status: Active » Fixed

Committed patch from #1 to dev.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.