1

I have expanded the article content type to include a few more fields and want to display an article node as a page. Each article node (content) I give an alias with the following pattern: press-releases/[name-of-article]

I've set up A "Press Releases" view which has three displays. Two of the displays are block displays and these work perfectly. I also want to make a page display with this view, and that's where I'm running in to problems. I want this view to be active for any node (content) that has the url press-releases/[name-of-article] and so I set up the view like this:

View - Page Display

And the Contextual Filter has these settings for the Node ID:

NID settings

But when I visit any press-releases/[name-of-article] it's like the Contextual Filter is completely being ignored and I just get the node spit out all the default fields as determined by the content type, and not according to the View's Page display. Why is this, and how can it be corrected?

1
  • If you are not getting an answer soon I'd post the exported view instead of screenshot. – user49 Nov 2 '11 at 3:38
5

In order to play nicely with other modules, views will not override any aliases that point to something already. You're trying to make a view show up on an alias that is already pointing to a standard drupal full page node. This simply will not work.

Options:

  1. Stop giving aliases to press release nodes so they are only available at node/nid
  2. Use a different path for your view so it doesn't conflict with your nodes
  3. Use Panels to override your full node page and show that view

Some other things to consider
A view is really useful for display a list of things, you should probably consider not using it as a node page in this way. You can get a lot of control over your page layout using the standard display tools Drupal 7 gives you.

Using Content: Nid as a contextual filter will not recognize a url in the form of press-releases/name-of-article. You would need to use Content: Title. You also don't need to specify the raw url value as a default value or add % in your view path. The order in which the contextual filters are configured are the order in which they are pulled from the URL.

7
  • Thanks. I was looking for a solution to this all day yesterday. But could you clarify what you mean by this: "You also don't need to specify the raw url value as a default value or add % in your view path. The order in which the contextual filters are configured are the order in which they are pulled from the URL." – Ben Nov 2 '11 at 12:35
  • And how would one implement Option 2 you outlined above? – Ben Nov 2 '11 at 12:53
  • The views path doesn't need the % placeholder for contextual filters to work. To do #2 set the path of the page to press-release or anything other than press-releases. In your Content: Title contextual filter you should set the When the filter value is NOT in the URL to Show "Page not found" since this makes the most sense in this case. You should also expand more and make sure Transform spaces to dashes in URL is checked. – rocketeerbkw Nov 2 '11 at 13:09
  • I did what you said for number two but it won't return anything but "page not found". When I go to something like press-release/debra-smith-named-vp-business-development, it just returns "page not found". – Ben Nov 2 '11 at 13:20
  • Did you delete the Content: Nid contextual filter? – rocketeerbkw Nov 2 '11 at 13:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.