By grove101 on
Hi,
I'm trying to create a view of current node's taxonomy terms which belong to vocabulary "A". Currently the code I'm using is as follows
$playerlist = taxonomy_node_get_terms(arg(1));
foreach ($playerlist as $key => $term)
{
$terms[] = $term->name;
//load the view by name
$view = views_get_view('player_view');
//output the items in the view with the node title as an argument
print views_build_view('embed', $view, array($term->name), false, 1);
}
It works but the number of views created is equal to the number of terms that are associated to the node from vocabulary "A".
How can I create one view of all the terms from vocabulary "A" in the current node ?
Regards
G
Comments
I don't think you need a
I don't think you need a view for that, if I understand correctly you want to know all terms in vocabulary 'A' that belong to a given node. If that is correct you can use taxonomy_node_get_terms_by_vocabulary() something like
ditto..
take a look at the many php snippets in the handbook for this precise need - you may not even need a module at all....
........................................................................
i love to waste time: http://twitter.com/passingnotes
My Bad .....
Hi Nevets,
Thx for the reply but I should have been more specific in my last post. The website is regarding variuos sports teams in the local community. I'm using the following modules
NAT "Node Auto Terms" - For each node created a taxonomy term is created and the term point to the associated node rather than the taxonomy page
Node Images - Each node will have an Image associated with it
Views Bonus Pack - Using Grid View
Team Content Type - For team details, history etc
Player Content Type - For player profile
What I want to achive is when the user clicks on a node of a Team it will display a short history of the team and a grid view of it's players. The reason I want to use views is I want to display the player images (node images) with their names which when clicked displays the player profile node.
Regards
G
It is not clear what
It is not clear what associates a player with a team (or a team with a player). I would have used a node reference field in the the player content type that referenced the team.
Your initial question "How can I create one view of all the terms from vocabulary "A" in the current node ?" is not something you do with views since views returns lists of nodes (not taxonomy terms). So the question is what associates the players with the team?
Ahh.... I have been working
Ahh.... I have been working for about 14 hours at a strech so my brain is all stuffed up
Well I have NAT (Node Auto Terms) module installed so when a Player Type Content is created a corresponding term is created in the vocabulary "player" and the term is linked to the node rather than to the taxonomy page
(so if the player type content title is Bob a new term Bob is created in Player Vocabluary)
When a Team Type Content is created the players are added to the team as tags (tags created by NAT) and a new term is added in the Team Vocabulary.
The tags in Team Content Type associate the Players with the team.
So here's what I want to do
Sample Data
Team : Eastern Knights
Players : Bob, Dean, Marc, Mike (all thses are nodes as well as terms)
1. Get all the term names from the current node (Eastern Knights) which belong to the vocabulary "Player"
- Since all terms are created using NAT, each term of vocabulary "Player" will have an associated node of type "Player"
2. Create a view of nodes which have title Bob, Dean, Marc, Mike
So my question should have been
How can I create one view of all the nodes with titles Bob, Dean, Marc, Mike ?
rather than
How can I create one view of all the terms from vocabulary "A" in the current node ?
Regards
G
p.s. Since Bob, Dean, Marc, Mike are nodes and terms as well I got confused myself :(
You can probably do what you
You can probably do what you want but I wonder if/why it is needed. Your team content type when displayed should be listing the taxonomy terms associated with it. If these are players and you have the terms linked to the play node you should already have the player list displayed. So what am I missing?
I need to display the
I need to display the players in a grid view with the players profile picture. Currently yes it working with the tags and I can edit the theme to display the tags anywhere on the Team node but that would not include the player pics.
I am able to extract all the player names from the team node but now what I am uable to do is embed a view in the node
The $playerlist in the above code is an array of play names. The above code only displays one player in the view where as there are about 15 of them in the array. Can't figure out why ?
Regards
G