How to embed a view into a node?

Events happening in the community are now at Drupal community events on www.drupal.org.
pkcho's picture

I was wondering if someone could recommend the best way to embed a view (related articles, etc...) in the body of a node... similar to how the Onion does it in the attached screenshot.

Thank you.

AttachmentSize
embedded-view.png400.42 KB

Comments

Views; node reference

mikeytown2's picture

http://drupal.org/project/viewfield comes to mind
http://drupal.org/project/panels will also do it

http://drupal.org/project/nodereferrer
and CCK's built in node reference will do it as well; as long as you select the related nodes.

Lots of ways

yelvington's picture

As usual, there's more than one way to do it. In the example you provided it might not even be a view. A CCK Node Reference field can provide an easy way to (manually) designate multiple items that should be displayed as link headlines. We have this functionality built into our news-editorial node type. Node Reference is handy because it ajax-autocomplete searches as you type the title.

If you really need a view -- for example, to query a database for items matching the parent node's taxonomy terms -- then you can create one that provides a block display, and embed it in an arbitrary node using the CCK Block Reference module.

A third way would be to override your node display using Panels, embed your block view there and pass arguments from the node context. That would make your block show up on every node.

A fourth way would be to invoke the view at the theming level -- in template.php, perhaps, providing a variable to be used in the page or node template.

There's probably a fifth and sixth way, too.

I do it the third way on our

pazzypunk's picture

I do it the third way on our website (e.g. http://www.sunjournal.com/local-sports/story/945715). Easy peasy! And panels makes it easy for you to add other elements to that page, too, and save the layout in code vs. in the database.

These are all great

pkcho's picture

These are all great possibilities. Now I need to figure out which methods suits my situation best.

If I use panels to override the node display, does that allow a panel to float within the content of a node?

LA Drupal video for Views Attach

stevenator's picture

There was a presentation at a meetup from Oliver Seldman posted to the LA Camp site reagarding this exact topic. Pretty quick and efficient.

http://replay.uci.edu/clients/drupal/Views_attach_-Content_profile-Flash(Large)_-_20101029_08.11.46AM.html

Broken link

ahimsauzi's picture

Hi Steve,

By any chance do you know of an alternative link to Oliver's presentation? The link above went 404 :)

Thanks,

Uzi

Try http://replay.uci.edu/clients/drupal

John Romine

Link on Blip.tv

oseldman's picture

LA Drupal also posts all it's vids and podcasts to the group's Blip.tv channel, http://ladrupal.blip.tv/. The Views attach vid is there at http://blip.tv/file/4314063.

Thanks guys!

ahimsauzi's picture

Really appreciate the follow up and patience!

Embedding view at an arbitrary location

oseldman's picture

Thanks for the mention Steve.

In addition to mikeytown2 and yelvington's excellent solutions, there's also an input filter that you could use to place the view anywhere in the body. http://drupal.org/project/insert_view lets you choose where you place a simple tag with the name of the view (or you can optionally add a display type and even a series of arguments).

Just note on the module page that there was a security issue recently discovered, however, the way you've described needing to use the view should not pose any risks. I'm also noticing that there is now only a dev version of the module available, but I'll post this anyway.

To answer your panels question (probably the most flexible of the solutions), you'd choose a layout that allowed the pane to be positioned how you need. If none of the default layouts got you there, you can create your own custom panels layouts pretty easily. If you get that far and are still having trouble using existing documentation, I can help point you in the right direction.

Oliver

Too many options... a good

pkcho's picture

Too many options... a good problem to have.

Thank you. I will play with these options this weekend.

In my limited experience with

pkcho's picture

In my limited experience with panels, I find that I can only place content into columns and rows, basically, content such as the body of an article will simply flow down the page in the same column. If I placed a panel with an image to the left of the body content panel, it will not flow around it.

Is it possible to have body content in one panel wrap around content contained in another panel, as in the example I showed in the Onion screenshot?

It will

perusio's picture

flow how you want it to as long as:

  1. There's a layout available that implements such.

  2. You select that layout. Also now there's a thing called panels fields row style in views where the sky is no limit.

Wow, panels is really

pkcho's picture

Wow, panels is really becoming an indispensable tool.

The screencast was very eye-opening, but I still don't see how it allows me to wrap body text around another panel. Am I missing the obvious? Am I just supposed to handle that in css and just float the embedded panel?

Thx.

What's about linodef?

pepe roni's picture

This module (http://drupal.org/project/linodef) can embed not only views but nearly any content, even field content, into a node (body)field. Check it out and you won't miss any of the above modules that only do a very little bit of linodef!


..........
Wilfried
Drupal: a CMS without typo in its name

Drupal 6 only

kristen pol's picture

There's no Drupal 7 version yet for Linodef. And, they should have thought of a better name :P

yelvington i agree with you.

jack.rudolph121's picture

yelvington i agree with you.

Easy way to report spam?

kristen pol's picture

Is the only way to report a spam account to create an issue report on drupal.org? I'm annoyed that this has been marked "won't fix":

http://drupal.org/node/226678

Making it hard to report spam means that people won't do it :/

That issue appears to be

christefano's picture

That issue appears to be about Drupal.org and not groups.drupal.org. Right now there aren't any issues about an alternative way of reporting spam here.

I think the reason is that until recently, downvoting was the method used to crowdsource the discovery of spam content. As of https://drupal.org/node/1116820, downvoting has been disabled.

ignore

kristen pol's picture

Whoops... that was supposed to be in response to comment above... ignore this.

Newspapers on Drupal

Group organizers

Group categories

Topics - Newspaper on Drupal

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: