views:

244

answers:

3

Hello all!

I am having fundamental problems understanding when to use a pathauto rule, and when to use a views page path. I have several custom content types, and I am using blocks to display certain parts of nodes on certain paths. Then I use a views page to display the main node on a path.

When I do this, I can't use pathauto, as it overrides the paths I set in views. Eg.. If I set up a views page path of "location/%", and set a pathauto rule for Location content types of "location/[title-raw]", when I browse to mysite.com/location/mylocation pathauto wins, and simply displays the full node. And if I can't use pathauto, I can't add arguments on my blocks, because Drupal doesn't understand what it's looking at anymore! Arrrg!

I've tried installing Util, and altering the weight of the modules, but that didn't work. But I shouldn't have to do anything crazy like alter module weights, right? There must be some basic flaw in my thinking.

How do you keep your paths and content organized?

Help me flow like water, help me become the cup.

+1  A: 

Right. The % is a views argument, views superceeds URL aliasing every time. Drupal expects anything after location/ to be the passed in value you are looking for which is why it doesn't understand, or you aren't getting the result you want.

Why are you using views though to control a node view? If you are adding blocks to a view, you should be able to assemble the data in views, and use the Block admin to set the path it displays on (location*).

Kevin
Kevin, thank you for the response!In answer to your question, "Why are you using views though to control a node view?" I don't know! I think this is the heart of my problem.It is my thinking that since there is a "content-top" and "content-bottom" block region... there must be a reason for not having a "content" block region. I imagine that is what a page view is for?
Dan Johnston
Thats where the side regions come in. But if you wanted a block below content, you would put it in the content-bottom.If this is an issue where you want a block to appear beside node data in a two column style layout, look into Panels.
Kevin
+2  A: 

Ok, I've solved my problem. The actual question I should have asked was:

How do you display a single node?

I was basically using Views to style a single node. Of course, this is not what Views is designed for. See others with similar problems:
http://drupal.org/node/400400
http://drupal.org/node/316907

My solution:

  • Let pathauto do all the work.
  • Add, arrange and style your content as desired at the theme layer.

In more words: remove views page view, taking the corresponding location/% path with it. Set up your pathauto rules the way you want. Copy node.tpl.php to your theme directory. Duplicate that file and rename it node-[type].tpl.php. Alter node-[type].tpl.php instead of setting up rules in Views.

For more help theming a specific CCK content type see:
http://drupal.org/node/266817

Don't forget! When using phptemplate node-[type].tpl.php suggestions, there must also be an original node.tpl.php template present in your theme directory or the template suggestion is ignored.

Hope that helps someone else!

Dan Johnston
A: 

There does seem to be at least one circumstance where this functionality is needed.

Say you have 5 'services' that are offered, and you display a list of these services using a view. So far, so good.

Now you add search, and the URLs that come up in the search are ugly (using /node/nnn), plus you want the found service to be displayed using the services view you created. You don't want to have two pages, one for many services, and another for just one service. So you add an optional argument to the view, so the view /services shows all, /services/title shows just the one of interest.

Now you can use pathauto to generate URL aliases, and magically all the services URLs now appear in the search result exactly as you want, /service/title.

The bad news is that the generated URL alias for the node 'wins' over the path in views, so when you enter the /service/title that worked to show the view with an individual node before, now it no longer works - it goes straight to the node.

So without a way to give some priority to the views path, you are still forced to theme two separate pages, one for the multiple services list, and another for the individual. You still get some mileage from pathauto, because the paths are nicer.

(I should say here that though I'm describing this in terms of views, the theming in my case is actually a panels page that includes a bunch of other stuff, including a view, so there's lots to duplicate (clone) to have one page for multiple services, and another for single services as a node. DRY says there should only be one display used.)

But it would be good to have a way to have pathauto generate the aliases, yet allow other defined paths to 'pick up' those aliases and do other things.

So... is it possible with configuration only, or does some PHP need to be hacked somewhere? Or is there some other way to accomplish the objective of one view, either multiple nodes or a single node depending on whether the argument is present, and nice URLs?

Many thanks for any great ideas!

Hacker

related questions