开发者

drupal link to view dependent on argument

开发者 https://www.devze.com 2022-12-16 11:08 出处:网络
I have a node (node a) with which various other nodes (node b/c/d/e) ref开发者_如何学Cerences. I can create a view with an argument as the node I\'m viewing, (node a), and get a list of the nodes tha

I have a node (node a) with which various other nodes (node b/c/d/e) ref开发者_如何学Cerences.

I can create a view with an argument as the node I'm viewing, (node a), and get a list of the nodes that are referencing that node.

Basically on node a viewing a list of node b-e.

I want to create a views page just for the node references of that node. But how can I pass on the argument to the new page?

Thanks.

Edit: I apologize for the confusing question.

Basically I have a movie node. I have many reviews referencing the movie node.

On the movie node I use argument: content: review_of to get a listing of reviews for that movie.

This is great, but because on the movie node there's only a few reviews, I need a page where I can see all the reviews per that movie. The question is passing on the argument for the movie from the view block (say, 3 reviews for the movie) to a view page (with all the reviews).

Ideally the url for the views page would be: /movies/movie-name/reviews

I have tried this with relationships as in Owen's answer, but was not able to make this work.


If I understand what you're saying, you're wanting to create a Views page that allows you to view nodes associated with a parent node (via a CCK Node Reference field)?

Once you setup your View, you can just pass the nid (or title, or whatever field you choose as your argument), to the URL.

So, assuming you have a Views page setup at: http://yourinstall.com/related-nodes

Just pass the argument in: http://yourinstall.com/related-nodes/5

The above (assuming your relationships / arguments are correct) will show all associated nodes with NID 5.

Here's an image of the views configuration I used.

You'll note the "path" setting on the views is "movies/%/reviews". I had two movies "Movie One" and "Movie Two", with a few reviews on each. You can then use http://yourinstall.com/movies/movie-one/reviews, etc... to see the titles of the reviews.

edit: Ok, so the clarification of the problem is, you have a Views block which displays a list of Reviews specific to a Movie. As well, you'd like the "more..." link to link to a Views page which display all the Reviews specific to that Movie.

This is doable via the Views admin, but does involve a bit of PHP code.

  1. Your Views block can be setup similar to the above Views page.
  2. Override your Views block Arguments (Review Of) Node: Title, and under "Action to take if argument is not present", select "Provide default argument" -> "PHP Code".
  3. The code you use is:

    if (arg(0) == 'node' && is_numeric(arg(1) ) ) {
      $node = node_load(arg(1) );
      return str_replace(' ', '-', strtolower($node->title) );
    }
    

In essence, the Views block acts the same (expects a Movie node title), but will use the code above to try pull the title from the URL (note this works fine with path aliases). The Movie node title is placed into the more link as well (see the above image) in the format "movies/[movie-title]/reviews", which will link to the Views page as expected.


Am I understand this problem correctly?

The real problem is that the "more" link in the block doesn't link to the proper view?

In other words, If your view is "movie_reviews", and on the movie node page you have: movie_reviews->block added on the side, within this movie_reviews->block the "more" link directs visitors to movies/all/reviews ?

Have you considered templating these changes? (manipulating the link within the block to work with the node of the currently being viewed movie node.) Blocks are very easy to theme.

I can give references on how to implement something like this if I this makes sense for your site.

0

精彩评论

暂无评论...
验证码 换一张
取 消