Fundamental understanding of how Views and Pathauto work together
Asked Answered
A

3

9

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.

Aquileia answered 26/5, 2010 at 14:15 Comment(1)
i have a related question: #2914722Theta
A
4

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!

Aquileia answered 26/5, 2010 at 18:42 Comment(0)
V
3

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*).

Virtuosic answered 26/5, 2010 at 15:3 Comment(2)
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?Aquileia
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.Virtuosic
D
0

In general is a good practice to theme the node page and do not let views generate additional urls. It can lead to several problems, as many modules link to the standard node page. Use views to generate listings that links to the node page.

You can also theme a node page without coding, using context or display suite modules.

Just let pathauto do the work, a good idea is to generate the alias based on the menu hierarchy, to have a consistent url scheme. Check out this question: Drupal 7:Pathauto patterns from menu structure hierarchy

Dressage answered 15/4, 2014 at 16:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.