Hi,

I have been trying to figure this out for too long now and need some advice please.

I have the path_auto module installed and have configured it to create the following pattern for my articles: articles/[nid]/[title-raw]

That works no problem. I have also created a view for the article with the path set to: articles/%/% and have set the arguments to read the first as the nid, and the second as null (ignoring it). When I create the new content (article), I put it in the secondary menu and see that the path_auto works. When I go to: http://www.kobo.com.au/articles/26/your-website-asleep it comes up as the default node view, however when I change the last argument to anything else like: http://www.kobo.com.au/articles/26/this-is-fake it comes up with the view I created.

So I see that path_auto gets its foot in the door first - how do I change it to display my custom view?

Thank you in advance.

Comments

kobocms’s picture

Is there not enough information? Why do all the other posts get answered but nit mine - did I miss something? Please, any advice or direction would be greatly appreciated.

nevets’s picture

Reading this I have no idea what your goal.

Views is not meant to display single nodes but that seems to be what you attempting. It would help if you stated your goal, what is the view suppose to display.

And as a general rule it is playing with file to have aliases the same as actual paths (in this case the one for views).

kobocms’s picture

Thanks for your reply nevets.

I never knew, or read anywhere that views should not be used to display a single page. That is probably a big no no then. I wanted to set up the articles page to have the ability to take another argument through the url which would format the page differently than the standard node display. Changing the node.tpl file didn't seem like the best option, but after much head scratching I have scrapped the need for a different format and instead linked the other site to a feed. Problem was the designer of another site wanted to use an iframe to display the articles on his own site. That's what he did for others but I basically removed that choice from him.

I still wanted to know the answer, and I think you pointing out that views is not designed for single pages made me realise how much i screwed this one up. I had always been convinced that views was an extension to node output, and took over the display if it was the same path. I think someone told me that and it has never left my head.

Thanks again.

nevets’s picture

While you can list single things with views it is not a great choice for overriding the standard path for displaying a node.

As for alternative ways of displaying a node my preferred method is to implement hook_preprocess_node and add to the template suggestions for a node. As a starting point your might try (this would go in your themes template.php file)

function phptemplate_preprocess_node(&$variables) {
  $option = arg(2);
  if ( !empty($option) ) {
     $node = $variables['node'];
     $variables['template_files'][] = 'node-'. $option;
     $variables['template_files'][] = 'node-'. $node->type . '-'  . $option;
  }
}

So given a path like node/1/simple of type 'event' you could use node.tpl.php, node-event.tpl.php (standard) and with hook implemented node-simple.tpl.php and node-event-simple.tpl.

Note the hook implementation above has a problem with an option value is the same as a content type.

Suggested reading: Working with template suggestions

kobocms’s picture

Wow, what ou just showed me makes the whole process more understandable now. I have read many books, visited many tutorial sites and have never seen this before. I only saw the code in Drupal when exploring Drupal's nuts and bolts and it never occured to me that you can hook into it.

It is most likely my fault for not knowing what to search for.

That devel module seems pretty cool. When I had it installed last time it crashed the site, so I got rid of it. I will try with an updated one.

Thanks a lot for your time nevets.