View within a View?

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
OldAccount's picture

I'm stumped trying to solve one of the last pieces of the new site I'm creating.

I've created 2 different Views to display 2 custom content types but would instead like to have a page display the latest 3 or 4 entries of either of those types. It seems like it'd be a View within a View, and I'm not sure how to do that, or whether it can be done at all.

Hope I'm explaining this well enough...

Comments

Not sure I understand your

TimNorman's picture

Not sure I understand your task. Wouldn't that just be 1 view that grabs both content types and displays the last 3 or 4 depending on the # you set it to?

Well, yes that's essentially

OldAccount's picture

Well, yes that's essentially what I want to do, but don't know how.

For example: Content Type #1 has 7 fields and Content Type #2 has 5, only Node Title and Node Body are mutual fields. I only know how to set the View to pull in all 12 fields, not the Content Type as a whole. Essentially I need to say "if Content Type #2 is the latest, only show those 5 fields and ignore the rest."

Does that help explain?

If that isn't exactly what

TimNorman's picture

If my answer below isn't exactly what you want, take a look at the mustardseedmedia podcast for Views Row Theming at http://mustardseedmedia.com/podcast/episode30 which might be a more involved answer to your view creation needs.

Hmm... I haven't tried

TimNorman's picture

Hmm... I haven't tried something like this but I think this would be possible. If I understand what your aim is then this is how I would set it up...

When creating the view choose node for the type.

Now in the edit view page choose node for the Row Style Type.

Under Filter add node: published (assuming you only want published nodes to be outputted) and node: type with the 2 node types you want included check marked.

Under Sort Criteria you may want to add the node: post date to sort the nodes in order from newest to oldest or oldest to newest. That's up to you own how you want to sort the 2 nodes types.

The view output should be a list of nodes of both content types you want in sorted order. To control the number of nodes presented just edit the Items to Display. From there just create a page or a block that will be set to display the list.

I hope that helps. Sorry for the delay in getting back to you.

Yes, that's it!

OldAccount's picture

Looks like the Row Style was the missing piece, I didn't realize what that did. Here I was adding every field individually, when I could have added the node as whole that simply. Wow, that's SO MUCH easier, thank you!!

2 views into 1

lyle@4fs's picture

Hi Guys

I know this is a bit off topic but I am currently doing a commerce site.

I would like to pull in a product type and a content type into 1 page using a view.

Is this possible? and I was hoping I could pull 2 views into 1 page, any suggestions?

I'm not familiar with Drupal

OldAccount's picture

I'm not familiar with Drupal Commerce yet, but with regular Views you should be able to pull in the product fields and content type fields into 1 view, you may need to add a Relationship to make the fields available.

To have 2 views on a page you can create Block displays and add both blocks to the page (either through the default Blocks module or use a module like Context).

This will work but I will be

lyle@4fs's picture

This will work but I will be having too much blocks, 2 for each content type.
This is for a commerce website.

I will look into context though.

Thanks

I did exactly that but am

lyle@4fs's picture

I did exactly that but am getting a syntax error, but thanks anyway!

I think panels is the only way I can do this because my view will not pull in both product types and a node.

Regards

its not off topic

shawn.palmer's picture

and I think that Panels is what your looking for

http://drupal.org/project/panels/

Thank you I completely forgot

lyle@4fs's picture

Thank you

I completely forgot about panels, although my site will be filled with views and panels, this will definitely work.

Five thumbs up!

A few suggestions

bbinkovitz's picture
  1. I can't tell exactly what you want to do, but you can use the Relationship setting in a View to pull in fields from another entity, such as a node that has your node as a Reference. If you have something like that and you want it all in the same View, try creating a Relationship.

  2. http://drupal.stackexchange.com is another great place to ask questions, in case you have questions in the future that aren't getting answered here.

Sorry guys I have been trying

lyle@4fs's picture

Sorry guys

I have been trying whole day, you just cannot pull a product type and content type into 1 view.

I tried using relationships but you cannot pull product type fields into a view pulling in a content type.

Very Sad though, I do not want infinite blocks, views and panels as this is a commerce site and I need it to be very user friendly.

I want to pull in product fields but link them to a node, sorry for the inconvience.
It's going to be a late night!

When you say "commerce site"

OldAccount's picture

When you say "commerce site" I'm assuming you mean Drupal Commerce? If so, I was under the impression they greatly improved the display setup with the addition of Product Displays:
http://www.drupalcommerce.org/user-guide/product-displays

Have you worked with these at all?

Central Ohio

Group categories

Topics

Group notifications

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

Hot content this week