Question on Views

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

Two students from my Web Programming/Drupal course came up with a Views question that I'm not able to figure out. Linking blocks to other blocks dynamically.

They want to have a block showing a list of vocabulary terms. In this case types of Recipes. On the same page they want to have a block showing all the recipe titles available for any category that is selected. Then, when the user clicks on a Recipe Title the full recipe displays (they already solved this part of the problem).

I was able to show them how to build a drop-down list of categories for a block holding the Recipe Titles but they want a list of recipe types in a block, not just a drop down.

I'm puzzled on how to link from a Taxonomy list in a block to a list of titles in another block.

Do you have any suggestions on how I would link between a list of taxonomy terms and a dynamic block of titles?

Thanks for your ideas and suggestions.

Peter

Comments

A couple questions...

JBack's picture

$term = array();
$term = taxonomy_get_term_by_name($title);
$terms[] = $term[0]->tid;

Something like this will allow you to get the taxonomy Id by the name of the taxonomy term.

I am a bit foggy on if you want the drop down list to list your entire taxonomy or specific terms.

Also, I am unsure if when a user selects an item from the drop down list, if you want another drop down list to be populated in the second block, or do you want a specific recipe displayed in the second block.

You may need to look into AJAX requests via Javascript and implementing them in Drupal Modules.

Many options

wylbur's picture

There are a couple of ways to go about this. It seems that they might be looking at a jquery type behavior. Clicking the link will populate another block with some views content.

Another approach could be accordions, using Views Accordion.
http://drupal.org/project/views_accordion

There is another option using views arguments. Add the taxonomy as an argument, and under action to take if there is no argument, select list summary. The next screen will ask for a style, and pick a list. Now when the view has no arguments, it will show a list of taxonomy terms. Clicking on a term will show the view of all the items in that taxonomy.

Views arguments will probably be key to making this work. Check that out.

JQuery

jessSchn's picture

If I understand what you are asking for - I think I've done a similar project recently.

I used a combination of Views Accordion and JQuery. You can see my project here: http://www.skybotsoftware.com/resources/document-library.

I have all the required fields from the Paper Library nodes pulled into the views accordion. Then I'm using some JQuery to hide/show the related information on the right side of screen. I've got each piece of information wrapped in a class that is the id of the node (title).

Hope that helps.