Hi,

I'm working on a new site - www.premiermatchtickets.com. The site is almost ready to go live but I've run into a problem that I can't figure out the solution to.

If you go to the site you will have a good idea about what I am trying to do.
On the first page you can see two main blocks - "Upcoming Matches" and "Premier League Teams".
I want to list all the games for a particular team in that team's node.
For example I would like to list all Arsenal's Upcoming Matches in Arsenal's node. So when a user click's on Arsenal they go to a pgae with an overview of the club and a list of all their games in ascending order.

I've tried to do this with views, but I can't figure out how to get a view to show Arsenal's games on Arsenal's page and Chelsea's games on Chelsea's page.

Thanks in advance for any help you can offer.

John

Comments

baxterjones’s picture

hi,
i had a similar problem which i simply fixed by using the taxonomy for drupal 6.x (you will have to enable it first).
with that you can add vocabularies, and to those vocabs... you could add terms then simply makes the links using the method "taxonomy/term/1" replacing the number at the end with the correct term number.

alternatively you could use the categories module, which is very similar although i haven't tried it with the new drupal releases.

hope this helps

nevets’s picture

How to you mark your content type as a Arsenal's games or Chelsea's games? As the other user suggested taxonomy would be one to do this.

WorldFallz’s picture

one way to do this would be to create a view for the games by team (with arguments) and then use http://drupal.org/project/viewfield to display that view on each team's node.

===
"Give a man a fish and you feed him for a day.
Teach a man to fish and you feed him for a lifetime."
-- Lao Tzu
"God helps those who help themselves." -- Benjamin Franklin
"Search is your best friend." -- Worldfallz

epicflux’s picture

You don't say how you're connecting the Teams to the Matches. Since these seem to be node types one way to connect them would be to use a node reference field. Put two node reference fields on the Match content type where you select the Home team and the Visitor Team. If you don't care for the Home vs Visitor data You could make this just one field called Teams.

Once you've got the connections established you need to use a Views argument.

First set your View up as a page, using the Home team node reference field as an argument. Test it out. Put the nid of one of your Team nodes into the View URL and you should see the related Matches show up.

Then do the same for the Visitor field. (Not if you only used one field).

Now to get your Views onto your Team pages:

Directly into the node body field use the Insert View Module.

Into the node template file embed with php.

Or set your View to also appear as a block.

If you want to use a block you'll need get into using Views Argument Handling Code. There's some examples on that page on what you can do with that code area.

In that Argument Handling code block you could put something like this:

if (($view->build_type == 'block') && (arg(0) == 'node') && intval(arg(1)) && !arg(2)) {
  $args = array(arg(1));
}
return $args;

This code checks to make sure you're outputting the view as a block and your on a node view page. If so, it sets the View's argument as the nid of the node you're viewing.

Then in your block's configure page you set the block to only appear on Team pages using the PHP visibility settings.

If you were to set it up as two separate fields, home and away, there are ways for you to still be able to combine the two results into one list... but I only have so much time this morning.

raplom’s picture

Thanks for all the feedback.
The site is using CCK content types for all the different categories of content. e.g. matches, teams, venues, competitions
The matches content type is built using node_references for Home Team, Away Team, Venue, and Competition.
A title for the match is then generated using the autonodetitle module.
Thanks epicflux, I've never used arguments before, but it looks like it will get the job done.
If anyone is interested I found this http://www.translationdesigns.com/en/unraveling-logic-views-argument-han... which helped with my understanding of views arguments.
John