0
votes

I'm working in Drupal 7, and trying to render a map & construct a list based off of content in a certain taxonomy. For example:

  • Various locations are created as individual nodes, with information (title, location, phone number, hours, etc.) attached.
  • One field in the location nodes is a taxonomy term: market. For example, East Coast or West Coast.

Currently, the only location this map exists is on a taxonomy-term--markets template, which pulls in all variables about each location in the appropriate market.

What I want to do is display a map on a different page (node--page) by selecting the market manually as a related field type. I can get the market name to appear, but I cannot get any information about the child locations! How do I do this? I've tried using a view and a block, but the template for the map is quite involved — and my understanding (which could be wrong) is that the variables I need to access cannot be "templated" from within the view/block system.

Anybody know how to go about accessing node information for a given taxonomy on a page template? Thanks!

1
you can use preprocess to add to $variables information about taxonomyFky
If I understand you correctly, you can use views. Install, enable it and then create a new view page. and on filter criteria add Content: Has taxonomy term. That way you could load nodes or get nid/s and load the node content.Sanjok Gurung

1 Answers

0
votes

Your map exists currently on taxonomy-term--markets which is I believe a taxonomy term template level rather than a page template level. By default the taxonomy page will be displaying the list of node that relate that tid term. On your template.php file add a taxonomy template preprocess function

function your_theme_preprocess_taxonomy_term(&$variables) {
     $nodes = taxonomy_select_nodes($variables['term']->tid);
     var_dump($nodes);  
}

The $nodes will give you a list of nids which you can node_load from them, will give you access to node info.

On page--node--page template level if you know the taxonomy term {tid} than you can create a page preprocess function. So on your {your_theme}/template.php

function your_theme_preprocess_page(&$variables) {
     //Assuming you know your {tid}
    $variables['mynodeinfo'] = taxonomy_select_nodes({tid}));
}

And on your page--node--page template output it by

var_dump($nodeinfo);