can views + pathauto work together?

#1.
suppose i want nodes of a certain type to be displayed thru a certain format of url.
for example i want nodes of type restaurant-review to be seen at
http://www.example.com/restaurant-review/joes-pizza
ok, that can be accomplished thru pathauto.

#2.
suppose i want nodes of a certain type to be displayed thru a certain view.
for example, i want certain fields to be not displayed, other fields to be displayed, the fields to be displayed in a certain order, etc.
ok, i can use Views and setup a page that does that at restaurant-review/ and filter by node title.

---

HOWEVER, if i try to do both #1 and #2 at the same time, when you go to the url, you see the default view (same as if you went to node/123). instead of seeing the specific view setup in #2 above.

note: the reason i want this to work is so that the drupal internal search engine works.

i am thinking the only work around is to just hack the search result function in the search module directory with a themed override.

Comments

garbo’s picture

I'm looking for the same thing here.

I want nodes of a certain node-type to be displayed through a certain view. And at the same time I want th URL of these nodes to be "nice".

I'll report if I find something.

Bram.

WorldFallz’s picture

So what you're saying is you have a view set to display at '/restaurant-review/joes-pizza' rather than the node?

Why use a view there-- why not just theme the node how you want it to appear at '/restaurant-review/joes-pizza' and set the view to appear at '/restaurant-review'? Another option is to use the panels module and create a node override pane for the individual nodes and use the view at the next higher level.

===
"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." - Ben Franklin
"Search is your best friend." - Worldfallz

garbo’s picture

Yes, my site is about monuments and I want all the monuments to have urls like: www...com/monument/node_title

The reason I don't just theme the node is that I'm using CCK and taxonomy modules and I want the content from certain fields being displayed in different columns. And some fields I don't even want to be displayed (the content of these fields is used as variables for the views rendering).

If you can point me to documentation about special node theming info that might help I would be gratefull.
Otherwise what I'm going to do now is to use custom_url_rewrite_outbound (http://api.drupal.org/api/function/custom_url_rewrite_outbound/6) to change the url's in links (e.g. from search pages) generated by Drupal.

From my searching I found that this is an issue that gave many developers a headache. It would be great if pathauto/URL alias and Views work better together on this matter.

WorldFallz’s picture

Based on what you've explained, I would suggest looking into a node override -- you will be able to slice and dice your node presentation in just about any way you like without having to resort to url gymnastics.

===
"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." - Ben Franklin
"Search is your best friend." - Worldfallz

garbo’s picture

Ah yes, that module looks promissing. I'm going to try it out.

But for D6 it's still in alpha stage so I think I'll have to wait a bit.

Right now I've done my gymnastics:

1. Views-page with URL: monument/monument_title (my preferred markup of the monument-node-page
2. URL-aliasses: monument/node_id (So I'm able to distinguish my monument-type nodes)
3. and on top this script in my template.php file:

function custom_url_rewrite_outbound(&$path, &$options, $original_path) {

  // Change all 'monument' node-types to 'monument/node_title'.
	if (preg_match('|^monument(/.*)|', $path, $matches)) {
		$parts = preg_split('!/!',$path,-1,PREG_SPLIT_NO_EMPTY);
		if (is_numeric($parts[1])){
			$node = node_load($parts[1]);
			$link = $node->title;
			$path = 'monument/'. $link;
			if ($parts[2] == 'edit'){
				$path = 'monument/'.$parts[1].'/edit'; // this is necessary to still be able to follow the edit-links
			}
		}
	}
}
xmvcnr’s picture

#1.
yes, what i'm saying is i have a view set to display at '/restaurant-review/joes-pizza' rather than the node/109.

#2.
for your 1st suggestion - i don't think i can theme the node (in row style: node rather than in row style: fields) if it includes CCK fields (which it does). is that true?
i'm in drupal 6.4 so i think panels are still on alpha as per drupal.org/project/panels.

#3.
a temporary workaround:
i setup all my pathauto paths to be THE PATH I WANT plus the superfluous appendage /regularnodeview.
then, in my page.tpl.php, instead of printing out $content, i print out eregi_replace('/regularnodeview','',$content).
thus i can tell pathauto all restaurant reviews have the automated url
/restaurant-review/[title-raw]/regularnodeview
but whenever a link to the node is displayed, be it within a list, or internal drupal search results, or etc.
it displays /restaurant-review/[title-raw] (without the trailing /regularnodeview string),
and
/restaurant-review/[title-raw]
is controlled by a view with a page path of /restaurant-review that takes a first argument of [title-raw].

i thought it was a good workaround, am i missing any opportunities to do it simpler?

WorldFallz’s picture

i don't think i can theme the node

One of the most incredible aspects of drupal, and with d6 it's only gotten better, is that everything can be themed. You seem to have gotten something that works for you which is, ultimately all that matters, but i don't see anything here that couldn't be themed the way you want.

You can theme the node, you can theme the full node page view (if you want to simulate what panels does) separately from the normal page view, you can theme nodes by content type, pages by content type (full node view), views, view rows, view lists, view fields, whatever. It's all themable. And if there aren't already core templates and suggestions available for what you want to theme, you can always create custom ones.

===
"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." - Ben Franklin
"Search is your best friend." - Worldfallz

xmvcnr’s picture

WorldFallz,

how would i be able to custom-theme nodes of each different content type using a different template file for each content type, if all of the different content types are all being accessed through the default way of looking at a node, e.g. node/123? (or thru restaurant-reviews/joes-pizza which displays the same thing as node/123 would, if i am NOT using views)

i am using my temporary workaround because it provides a way for nodes of each content type to be accessed through a different view. one view applies to each content type. so restaurant reviews can be accessed through 1 view, and other content types could be accessed through a different view, etc.

could this be done any other way? i guess my workaround is working fine but i'm always wondering if i'm doing things the hard way.

WorldFallz’s picture

Theming nodes by content type is built in-- you can simply copy node.tpl.php to node-story.tpl.php and it will be automatically picked up by the theme engine for nodes of content type 'story'-- then just edit however you want. If you look at the links I provided above, you can easily see what template files are detected by default.

You can also create template files for page-story.tpl.php if you want to change the entire full node page layout per content type (which is something panels can do through the UI instead of changing theme files) but afaik, that's not provided by default, you need to add it through a preprocess template.php function (also explained in one of the links above).

===
"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." - Ben Franklin
"Search is your best friend." - Worldfallz

xmvcnr’s picture

useful, thanks. that was the clarification i needed. my workaround should be unnecessary i might reconfigure my system a bit.

WorldFallz’s picture

welcome-- good luck :P

===
"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." - Ben Franklin
"Search is your best friend." - Worldfallz

xmvcnr’s picture

i am finding the specific example i need here:
http://drupal.org/node/266817

the thing is that when you use Row style: fields instead of Row style: node
i think it gives you more control over the formatting of each row, for example for an image cck field, you can choose to
show the path to the url, or the image itself, or etc. etc.
whereas it is harder to find that amount of control over formatting a specific field with the $node variable.

gakshay’s picture

Hey xmvcnr,

I agree with you and ended up in the same problem as you said (even after two years) :( I too need the same functionality (which i assume its very basic) i.e. different url alias for different content types and each alias shall pick up the right View to render.

Having row-style as field gives lot more power in adding fields and the action on them as compared to row-style: node.

I just need to ask what solution exactly worked for you ?? I know anything can be themed but it doesn't seems to be wise to add all the fields in node view (row-style: node) and dig deep when row-style: fields do all the hard work for you without any pain :)

Sugesstion/feedback ??