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

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.

Related

Views and Categories...?

it's about this page: http://veagues.com/
Hey guys,
I've made a block-view with drupal that let's me sort my videos by a certain category, in this case "funny","epic","plays", "contest"...
The problem is: When you sort it by the certain category and click on a video and continue to click the "next" button, you will go threw all videos, instead of only the videos of the category...
My Question is: How can I put a filter on the nodes when i apply another category on the bottom block?
Thanks already!
If you're using Views, you should be able to filter the main block by the same taxonomy term.
Try adding a Contextual Filter to that block too. If there's a taxonomy term ID in the URL the block gets filtered by that Term ID and if there's no result, the block shows all the videos.
EDIT -----------------------------------------------------------------------------------------
You may need to try & understand what goes on when you make a selection in Drupal.
1/ The taxonomy term page will list all the content affixed with a specific term. The term tid can be seen in the URL, unless an alias have been created. A block can retrieve that term id, whether there is an alias or not.
2/ The node page will give you access to a specific node, but any block on that page should be able to access the term id of that specific node.
If you know where you are, it becomes easier to retrieve the info you're looking for. On the other hand, you may have to reconfigure a specific page in order to add the necessary extra block...
That can be done with templates but you could also have a look at Panels.
The Panels UI makes it easier to configure the page you're looking for without having to mess with code or templates, or both.
There's a lot of free video tutorials out there, search for Views & Panels.
If you want to have a look at preprocess functions, you will definitely need to download the Devel module...
...but have a look at these sites first:
http://codekarate.com/
http://drupalize.me/
http://buildamodule.com

I need to use a View as a 'Content Type' in Drupal 7

I'm creating a view that needs to display two content types - a normal content type, and a view. The view needs to display three items in a row - the first two items of the normal content type are the first two items in the row, and the view needs to be the third.
I have tried Viewfield and Views Field View, and neither have done what I need them to do. I need to be able to add the view as one of the 'Content Types' that the view is picking up.
Is there a way to do this Viewception?
So, if I'm getting this right, you need a view to display a normal content type, and then a view along with it?
You can always make a view of the content type, and then attach another view to it.
What is the source of the attached view's data?
man dont do this, it will be very slow query and it will kill your webserver after a few page requests
you need to build this as a custom block with a custom query (or event multiple queries), but also check your query speed. leave me a message when you need help with building custom block or building the query

drupal replacing default nodes with views page

I have created a page view using field style to display a list of teasers as I want. fields configuration in views allows us to link the field to it's node. but what if we have created view for node detail page and want field to link to it's relevant view.
I had the same question, and after a bit of research this is what I've concluded:
The views module isn't intended to replace a default node view. I say this because of the level of difficulty involved in doing this and the lack of information on how to accomplish this. Ryan Weal has posted a way to accomplish this by editing your node template that doesn't look too difficult to accomplish, and here is the link.
However, it seems that a more popular solution, especially if you are like me and don't like to get into editing theme files. You can use the Display Suite module to effectively reformat the default node content as you would like.
I'm not sure if I understand you properly, but it sounds like you are wanting to display a view in a page view of a node?
In order to do this, you could:
create a small module, using hook_nodeapi() or one of the D7 replacements for this function in order to insert the output of the embedded view into this page's content, by conditionally adding a $content element when the node is of the appropriate id
or (easier, but requires allowing input type PHP) embed the view right on the page.
http://thedrupalblog.com/embedding-view-drupal-6-using-views-embed-view for information on embedding views

Drupal: Content in blocks from node_reference fields?

After only a few weeks of working with Drupal I've come up with a recurring problem, which I don't really have an optimal solution to, so I'm hoping that someone here might be able to give some best practice pointers.
What I have is a region inside my node.tpl.php, which is populated with blocks that display content from two different CCK fields of the type node_reference. This works fine when displaying a single node. The problem appears when I need to use a view.
For example, lets say I have a news listing, and a single news item view. When I display the single news item I can use the news node node_reference field to reference whatever material I would like to have in my sidebar, but when on the news listing view I would like to reference nodes separately. What would be the best practice to solve this?
I'm having a few ideas, but none seem like the logical choice, how would you do?
My understanding of your problem is that you don't want the blocks to display on the view page and you want the block information displayed inline with the node.
The first part is easy, you can modify the block visibility settings to not show up on the path where you have the view.
The second part will depend on how you set up your view. If you are using fields you can simply add fields for the node_reference and they should display. If you are using a node view, you will have to override the template and create a template which displays the node reference field.
If you want further explanation please comment and I can clarify
After reading my question I realize that it was explained pretty badly, so I'll try again, and also tell how I solved it.
The Problem
On normal "pages" (when displaying only a single node), I have a sidebar that shows something similar to banners, which are either random, or I can select one or many that should always be displayed on the sidebar. This is solved easily when displaying a single node, using a CCK node_reference field. The problem is when using a View that displays multiple nodes, for example a news listing-
The Solution
In my case I could solve this by creating additional fields on my default Page content-type. These fields were called view, display and arguments. In my tpl.php I then embedded the news listing view inside a page, lets call it News. This way I gained great flexibility, and also helps the News page to know where it is located in menu structure.
Final comments
I have yet to discover if there are any drawbacks or dangers in doing this way, but if there are, feel free to share them with me :)
I tend to want to create my own modules, which create blocks and reference the database directly. Then I put the blocks inside of panels, this seems to be more flexible for me than using views and cck fields etc ...

Assign a taxonomy term to a view instance

Is there an easily managed way we can assign a specific taxonomy term to a specific instance of a view?
We're using the callouts module for Drupal, and it works great for nodes/pages we have in our site. But we have a handful of Views that are displaying as a page, but we cannot assign a specific taxonomy term to a specific instance of that view.
The view itself is pulling in lists of nodes based off of a taxonomy argument:
Example On the bottom left, we have some callouts, but they're shown randomly because we can’t assign a term to that page to show specific callouts.
There's 7-8 of these pages, and they all use the same View, but just passing different data through the argument. we've tried assigning the callouts we want to the taxonomy that is used to create the view, but that didn't work either.
Without changing the view output (for example, from a page to a block), how can this be accomplished?
Even if you could assign a taxonomy term to a view, I think it would not help in this case. Blocks are not aware of their context at the time they are rendered, so they have to look at the url to retrieve information about the node that's being displayed. The block checks if the page displays a node; if so the node data is loaded. The callouts module also works like that, as is explained on the module page. Since a view is not a node, the block will not render. To make this work, you would have to alter the callouts module I'm afraid.

Resources