Drupal: Sub views? - drupal

I have a parent/child relationship (based on the cck node reference field).
Recipe Group contains a node reference to the type Recipe. It's a 1 to many relationship.
What I need to do is create a view that displays the recipe group information, and then under it, the recipes that have been assigned to it's cck field.
So
RecipeGroup1 - Title
Recipe1, Recipe2, Recipe3
RecipeGroup2 - Title
Recipe4, Recipe5, Recipe6
etc etc
I've created the view to pull the list of recipe groups.. but I have no idea how to retrieve the recipes that belong to the group?
I've tried googling, but we are on a tight time line and would appreciate any assistance.
Thanks.

Take a look at http://drupal.org/project/views_field_view. It lets you combine two views (groups, recipes), inserting the recipes view as a field into the groups view. Using this, you can have as many fields as you want for the group.

You can use the Views attach module to associate a view with a specific content type and display that view on that content type's node page.
There is a webcast here that demonstrates how the module can solve a problem similar to yours.
However, the webcast assumes your nodereference CCK field is on the child content type and is pointing to the parent content type, not the other way around like you have it.
Instead of using the nid of the recipe group as an argument to the view (as shown in the video) you may be able to use one of the recipe group's tokens (the nodereference field referencing its children). You can see that option at 9:32 in the video.
Whatever you decide to do, I think Views attach will likely be your answer.

Include the cck reference node field as an output field to your view. After, you can 'rewrite the output of this field'.. so that it looks however you want.

add noderefernce field in to views fileds
select check box to group field result in node ref field settings
theme that field as you want

Related

Relating different content types in Drupal 7

I've just started learning Drupal 7 and I'm stuck on a problem.
I want to relate different content types using taxonomy. For example, how can I display blogs related to an article?
I know how to relate articles and basic pages but I don't know how can I relate blogs with articles?
Please help me.
Use reference field in blogs content type
like
field name is: related with
field type is reference
set reference type node
set node type is article
optional multivalued true
Now you have a relationship field in blogs
Now you can do every thing with this relationship
Hope this make sense
Thanks
You would create your taxonomy vocabulary and supply it with terms. On its own, this doesn't do anything, you need to add a field to each of your content types that are using this taxonomy.
If you go back to your content types, structure > content type > article. Here you would create a new field of type term reference. Inside the settings of the field you'd select your vocabulary and then also the widget eg. select list. You can re-use this field on the other content types where you want to share this vocabulary.
If you go back to your content for the types you added this field for and populate them with selections, when you view that page by default the term will appear as a link. If you click this link it will take you to a page view that will list all the other nodes that have that term form that vocabulary.
More information on taxonomies: https://www.drupal.org/docs/7/organizing-content-with-taxonomies/about-taxonomies
If you are creating a view and want to know how to pull in different tagged content there, I'd recommend reading this post which outlines the steps to do so https://drupal.stackexchange.com/questions/205921/how-do-i-show-related-content
The process:
Basic stages:
Create a “Content” view-block.
Add a contextual filter: “Has taxonomy term ID”.
Choose “provide a fixed value”.
(From type): “Taxonomy term ID from URL“.
Checking:
• Uncheck “Load default filter from the term page”. • Check “Load
default filter from node page, that’s good for related taxonomy
blocks”.
• Check “Limit terms by a vocabulary”. • Check your desired
vocabulary.
Select “Filter to items that share any term”.
Go down and check “Reduce duplicates”: This will several terms that relate to the same page – To appear. Only one will of them will.

How to display event's views block inside another content type's content section with only events related to that content alone?

I am working on a drupal7 site. The scenario is that, there are 2 content types namely singers and events. When i am adding an event, i need to add an event to a singer, so that when i am viewing a singer's node page, i can see block containing events related to that singer alone.
I have done the events block inside the singer's content page(Using the views block). But it displays all the events and i want to display the only the events related to that singer alone. I have tried to make it using term reference or some other stuff. But nothing have worked out. Can anyone help me out to get this scenario working. Thanks in advance.
First of all, you need to link those two content types using Entity Reference module. Have a look at this answer, where I have just explained how to do so to another user.
I assume your block is being shown as a view from Views Module. However, up to now you have not been able to filter the results by singer. Once you have properly linked both content types, you will have to edit your view and add a contextual filter. When I first faced this problem, I used this guide to solve my problem. Basically you filter the Event list to show only those whose "Singer" id is the n-th parameter in the URL (node/nid).
First, why term reference when you have 2 content types? Inside your singer content type add node reference to event content type. The same thing as term reference, but obviously, you have to reference a node, not a term.
Second, in your view you must have the contextual filter that takes singer id.
Third, I'm not sure can that work with block display, but I'm sure it works with embedding view, so my suggestion is to created view display of "embed" type and to embed it directly into singer content type template. This way you can pass singer id (you have it available there: $node->nid) parameter easily.

Drupal 7 - Term reference field: how to add new term?

I have some texonomies in my Drupal website. Some of them have additional fields. I have some fields of type Term reference in my content-types.
When I am creating a new node of a content-type, I would like to have the ability to add a new term to the taxonomy while I'm filling the form of the Content-Type (with an "add item" link/popup...).
I can do that if I use Entity Reference fields, but I cannot using Term reference field. Could you help me, please?
Thanks
UPDATE: I installed "Taxonomy access fix" module (https://www.drupal.org/project/taxonomy_access_fix) and it allows me to set capabilities per each taxonomy based on user role. Now I only need to add a new term to a Taxonomy on a form level using Term reference field (I canno use autocomplete because I need the user to see all possible values like with a dropdown).
Any help?
If you change your widget to the autocomplete widget, it will let you add new values.
I agree with #Dark FlameS, in fact we are using the autocomplete widget for some of our students to add types of trees in the biology lab and they tag each with the scientific name.
And since we dont know these scientific terms, we let them add taxonomy terms to the list.
Slight difference however, we use the module Autocomplete Deluxe. Works like magic for us.
You are able to see what taxonomy terms are already available by clicking into the text area.
And as you type a taxonomy term, you will see what other terms are similar. If a tag is new, it will be added. one thing, dont allow them to delete your tags. We learned this the hard way.
See the image below on what it looks like as you add a tag.
Above is what you will see when you are adding the taxonomy field in your content type, this is after you install the Autocomplete Deluxe module
Above is What the user sees when they add or select a taxonomy tag.

Drupal 7: Create glossary with views, but sort it by a field other than the title?

I am trying to create a glossary view but the one that Views provides uses the first letter of the node's title. I need it to use the first letter of a field named Artist in my content type. I've tried making a new Contextual Filter and match it up with the one provided by the glossary view but the Glossary mode is not even an option, which I find to be very odd. Anyone have any ideas? :-/
You're doing the correct thing by copying the existing Contextual Filter, for both Page and Attachment displays. Your main problem is figuring out why the Glossary mode option doesn't appear for your field. With Views 7.x-3.3, it should do if your Artist field is a Text type but I suspect yours is actually a List or Term reference.
If it's a List (text) field: upgrade to Views 7.x-3.x-dev and the glossary mode option will be available.
If it's a Term reference field: add a Relationship for the Term or "Taxonomy terms on node" and then you will be able to use the Term Name as a glossary argument.
If it's a Node reference field: add a Relationship for your node reference field and check "Require this relationship". Then update the Content: Title contextual filter in both the Page and Attachment displays to use this relationship. This tells the view that the filter should be based on the title of the related node instead of the parent node.

Drupal Views of nodes to show node comments

I've encountered a Drupal problem: I'm using the Views module for rendering nodes of a kind, based on the user id of it's author (it is a Content Profile actually). I want the view to show the comments for the node, just like in node/%. I could not find any option in views or any relevant module. Am I in the wrong direction and should reorganize stuff for this...?
Any ideas, how can it be done?
Regards,
Laci
Using views is really not the best plan of action. You should instead create a node template in your theme and customize it. If needed you can put some logic in a preprocess function. It requires more coding but will get you where you want.
If you use view node display type
Check in it's settings show comments
if you use view fields display type
Use relationship to comments and select fields you need and theme them
I know this is old request, but I was just struggling with the same issue and came across this post. I thought it'd be helpful to share my solution.
I'm using Drupal 7, with Views 3 and Display Suite.
In your view, choose the display in question.
Under Format, click the first link to the right of 'Show'.
Choose 'Content' (or 'Display Suite' in my case).
Click 'Apply'.
On the next screen, you'll have the option to 'Display comments'. Check this box and save your view.
You should now see the comments displayed under each item in the view.
You could create a second view (with URL e.g. /comments/% where the placeholder will be the node ID, and not the comment ID) that lists comments for a given node, with a contextual filter to only show them based on the NID in the URL.
Then, add that view to the footer (as a 'view area') of the single-node view you've already got.
There's some tweaking required for layout (inline fields etc.) but the basic structure should work.

Resources