I really need to display all the nodes submitted by a user on the page which has a path consisting of the website and her username only, like, for instance, http://mysite.com/fenicia.

The problem with views is that they do not accept any arguments immediately after website url, that is I could easily list all the nodes by adding any word or letter before her username like http://mysite.com/ls/fenicia. However, I don't want to put anything between website url and usernames. Any ideas?

Comments

vm’s picture

two methods off top of my head.

create the long url for views, then use viewsalias.module

or embed the view in a node using embed views and url alias the path

yngens’s picture

Thank you, VM, for suggestions. I have just tried first method. Unfortunately, viewsalias.module works with specifically taxonomy terms (and I don't want to create taxonomy term per user), seems it does not support aliasing views with paths, consisting of usernames as arguments.

http://drupal.org/project/view_alias says:

View Alias now utilizes the pathauto API features and adds a fieldset on the "Automated alias settings" tab named "View Alias settings". Under this tab, each view that has a page display (could be more than one) and a term id argument will be listed.

To get the correct views to display:

View must exist and have a page display.
Under Arguments, View must have an arg of "Taxonomy: TERM ID".
Under Validator options:
Set Validator to Taxonomy Term, then select your term vocabulary.
Set Argument Type to "Term ID"

Thus I am left with only one choice I believe. Going to try second method.

yngens’s picture

Just came to my mind, that I can't achieve my goal by embedding views within a node. Because, that node also needs some kind of alias itself and I don't want anything between the site's url and usernames. That is url like

http://mysite.com/1st-username has to list all the nodes created by user 1st-username,
http://mysite.com/2nd-username has to list all the nodes created by user 2nd-username,
etc.

So there is no room between 'http://mysite.com/' and 'usernames' for putting node's alias.

I still hope someone can tell me a workaround for this problem.

yngens’s picture

Well, the node could be put in frontpage. I did that. So I embedded my view in node #40 and have put node/40 in forntpage so that it could be accessed directly at http://mysite.com. After adding username to the url of the site like http://mysite.com/Fenicia, responsible view lists all the nodes of all the users. Unfortunately, a username is not accepted as argument here. Same result at http://mysite.com/node/40/Fenicia

I am afraid embedded views respect actual node path even if put on frontpage.

yngens’s picture

I even tried to put the following code into page.tpl.php to avoid using any nodes:

if ($is_front) {
$view = views_get_view('usernodes');
print $view->execute_display('default', $args);
}

It correctly displays the view on fronpage, but, unfortunately, does not accept username in the path as 1st argument.

yngens’s picture

Getting desperate to solve this. I tried one more failed way.

1. Have all the usernames aliased with pathauto so that they followed directly after Drupal website's base url. That is, you have to take word 'user' (or 'users') which usually goes between the base url and username, so all the 'http://mysite.com/user/username's become 'http://mysites.com/username's.

2. Put this code into 'user-profile.tpl.php'

$view = views_get_view('usernodes');
print $view->execute_display('default', $args);

Now instead of profile page we were supposed to see all the nodes, created by the username in the path (the view does that). But, alas, it does show all the nodes. Again, usernames are not accepted as arguments by views :(