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:
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!
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 nid
s 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);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.