Suggestions to make Views Menu Tab content URL human readable

Events happening in the community are now at Drupal community events on www.drupal.org.
JSCSJSCS's picture

Using PathAuto and when displaying a node, the url is human friendly as in:
example.com/article/article-title

Now when I add a view as a menu tab to the node, the view path must be in the form:
node/%/premium-content

Where % is the contextual filter of "Content: Nid" in order for the menu tab to display next to the "View" menu tab for the node.

The trouble I have is that because the view path must be in this particular form, the url of the content when the "Premium Content" menu tab is clicked looks like this:

example.com/node/xxxx/premium-content

As a UI perspective, I would rather it show this:

example.com/article/article-title/premium-content

I can't seem to find a way to do this. Any suggestions?

Comments

% is just an argument. In the

value's picture

% is just an argument. In the View setup you should be able to change the arguments expected value from Content: Nid to Node: Title but that still won't match the PathAuto alias most likely. If you have PathAuto setup to not remove words less less than certain length etc, you can use Node: Title and transform it to all lower case and check "Replace spaces with dashes" and it should work. But in most cases PathAuto value is not an exact match of the Node: Title.

The easiest way I can think of is to have a CCK field that matches the PathAuto fields value. It's not clean but it will do.

Then change the argument to Content: New Field (where New Field is the name of your duplicated path field) and edit the path to be
article/%/premium-content

There is some more info here though that may be useful http://drupal.stackexchange.com/questions/4409/setting-node-title-as-vie...

Thanks for the suggestion

JSCSJSCS's picture

I should have mentioned I am using Drupal 7 and Views 3, so CCK Fileds and the subpath_auto module are not really applicable.

You do offer some ideas I need to look into further to see if they will work. I'm not sure how to get the automatically generated pathauto value and automatically set a path placeholder field to the same value at node save/creation. Not sure if Rules can see that pathauto variable.

James Sinkiewicz
Drupal Site Builder and Generalist
http://MyDrupalJourney.com

I don't know of a way to do

value's picture

I don't know of a way to do it dynamically. It should be possible though with a trigger.

This may shed some light on the solution http://drupal.org/node/327961#comment-3477596

Solution found

JSCSJSCS's picture

I forgot that I used this on another project that dealt with page manager aliases, but I guess the concept was similar. It does not work as completely with views/context as it did with my PM/context issue, but at least the url is consistent.

All I needed was the Extended Path Aliases module.

http://drupal.org/project/path_alias_xt

This module basically accomplishes a simple task that I needed; if an alias exists and you create a path that is an extension of that alias, then that alias and your extension is used as the path.

So in my case, since "node/node:id" was aliased with pathauto to "record/pathauto-node-title", then my views menu tab that had its path set to "node/%/premium-content" displays in the browser as "record/pathauto-node-title/premium-content.

I cannot use the new alias as a context module path (not working like it did for PM), but that is okay for now.

Thanks for the suggestions!

James Sinkiewicz
Drupal Site Builder and Generalist
http://MyDrupalJourney.com

RE: Solution found

jay.lee.bio's picture

James, thanks for sharing the link to that cool module. Can you post a live link to the solution? I think I might be trying to do something similar but can use some help visualizing exactly what you were trying to accomplish.

Nothing Live yet

JSCSJSCS's picture

Sorry Jay, can't show you anything live yet. The problem is simply that some modules require you to enter a path explicitly in order to do their magic. A views page configured with a menu tab is one such animal.

Because of that, when you load that page, the url in the browser also shows that explicitly named path.

So even if you have PathAuto set to display article node paths as "article/article-title", in order to get a menu tab on that page, the path has to be set to "node/%/menu-tab-title". When someone clicks on that link they see a URL of "node/%/menu-tab-title" and not "article/article-title/menu-tab-title.

If you try to change the views page path, the menu tab will not display. It has to be literal. The path_alias_xt module makes the URL in the browser window look correct even though the view path is set explicitly.

As for the other references, I found that in the context module, when you are setting a condition using a path, that when the using a page manager path and the path_alias_xt module, I can put the alias in the context condition path textarea and it works. I do not have to use the "node/%/title" explicit path name. I can use the path_alias_xt path name and it works.

However, I cannot use the path_alias_xt path name in the context module conditional path when the path is coming from views for some reason, but like I said, I can live with that.

James Sinkiewicz
Drupal Site Builder and Generalist
http://MyDrupalJourney.com

San Diego DUG

Group categories

Event Classifications

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

Hot content this week