1

I'm trying to get a Basic Page's Banner Image field to display on its Basic Page AND any of that page's children. Those children may or may not be the same content type.

Ideal outcome:

  1. The content editor creates a new Basic Page called About Us
  2. They upload an image for the Basic Page's Banner Image field
  3. They create a new page of any content type, let's say a Contact webform
  4. Contact's menu settings make it a child of About Us
  5. Contact and About Us both automatically show the Banner Image that was set in About Us

I've tried solving this with php in my page template and with views & blocks, but I'm not getting very far. Any ideas?

  • The view needs a contextual argument for one to even select the node that contains the banner. The banner doesn't necessarily belong to about us. One way to do it is create a banner entity or content type, and then reference it via field on a content type - build your view off of that value. – Kevin Nov 21 '16 at 19:52
  • Right, but what kind of contextual argument? I’ve been messing with the node hierarchy module, and I can use that with views to show fields from child pages on parent pages… but not vice versa :S Not sure if I'm missing something or if the module’s just buggy. – moca Nov 21 '16 at 20:14
  • If you're looking for a reference field route, you add the current node nid as a contextual argument, then relate the reference field, and use its fields to populate the block (or better yet, as rendered entity output). Basically it says, given current node, is foo field populated, if so use its nid value to pull bar node, and display as foo_display. – Kevin Nov 21 '16 at 20:34
  • I think this is almost the solution I need, thanks so much for your suggestions. I’m not sure what you mean by “a reference field route” though. Would that mean adding an entity reference filed to my Basic Page and entering all the sub pages there? – moca Nov 21 '16 at 20:56
  • Using a reference field to reference a Banner content type. The Banner has your fields - then on the basic page content type, for example, add a content reference field, the type is Node, and point it at the Banner content type. It will pull that in. Then you can reference that banner from any page - it will also give you the flexibility to use whatever banner wherever you want despite content hierarchy. – Kevin Nov 21 '16 at 21:00
0

For posterity, here’s the solution I came up with.

I turned my Banner Image into its own content type, used the nodeblock module so it would automatically be usable as a block, and then just scoped that block to myParentPage and myParentPage/*.

It’s not the elegant solution I wanted, I was hoping to give the user a one step process that would also keep them from creating top level pages without a banner image. But it gets the job done, so I’m happy enough.

Thank you Kevin for getting me on the right track!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.