Currently I've set subdomain to maps organic groups to subdomains.

For example I've a group called "group name" so pathauto+subdomain correctly create "http://group-name.domain.com" (where domain.com is my domain). The subdomain works perfectly and it displays the content of the group.

Now I've created a node for this group (node audience), the title is "first news posted in the group". I've set [title-raw].html in pathauto settings so the the URI of this node is:

http://domain.com/first-news-posted-in-the-group.html

What I'd like now is to have the subdomain for nodes posted in the group, like:

http://group-name.domain.com/first-news-posted-in-the-group.htm

instead of:

http://domain.com/first-news-posted-in-the-group.html

Is this possible with the current subdomain+pathauto implementation? Does this need only a different configuration?

Many thanks!

Comments

finex’s picture

I've done some tests. In all of them I've set "[subdomain]" as path pattern for group node type.

If I manually set the alias of a node posted into a group to:

~group-name/title-of-the-post.html

the URI will be:

http://group-name.domain.com/title-of-the-post.html

which is correct.

So I've tried to set the following pattern into the default path pattern:

~[ogname-raw]/[title-raw].html

This partially works: nodes posted into a group now are correct but nodes which aren't posted in a group became:

~/title-of-the-news.html

So the final URI is:

http://.domain.com/title-of-the-news.html

which obviously doesn't work.

Finally I've done one last test. I've set the following pattern for the default path pattern:

[subdomain][title-raw].html

In this case "subdomain" pattern is not used and the final URI is:

http://domain.com/title-of-my-node.html

(like when the pattern is [title-raw].html)

finex’s picture

Version: 6.x-1.5 » 6.x-1.7
finex’s picture

I've looked at the demo site (eslwell.com) which does exactly this thing. It should be interesting to know how it has been configured.

finex’s picture

I've tried to look the source code but I didn't understand how to configure it... :-(

redben’s picture

subscribing

redben’s picture

I had the same problem. but it found that this issue is only related to group content created prior to setting pathauto alias. I went and created new content and subdomain works perfectly.
The pathauto for group content should be [subdomain]/my/custom/path/[title-raw]
which results in og-name.example.com/my/custom/path/my-title

redben’s picture

Category: support » bug

Plus its seems like subdomain gets out of sync when you update path aliases for existing nodes :

  1. set group content pathauto to [subdomain]/path1/[title-raw]
  2. Create content "Content 1" for the group1
  3. Everything is fine, you get group1.example.com/path1/content-1
  4. change group content pathauto to [subdomain]/path2/[title-raw]
  5. go to admin/content/node
  6. Check node "Content 1", and select "update path alias in the update options
  7. url for Content 1 is now www.example.com/path2/content-1
finex’s picture

Now the path alias of nodes posted into groups are correctly generated. But there is still the problem of nodes which aren't posted in a group, they became:

~/title-of-the-news.html

instead of:

title-of-the-news.html

So the final URI is:

http://.domain.com/title-of-the-news.html

A workaround is to duplicate the content type, but I'd like to have only one content type.

Googling around the net I've found this:

http://sefikuv.net/~computers/drupal-how-i-got-subdomain-pathauto-module...

The suggestion is to hack the path module for removing the unneeded string "~/" in the path:

function path_set_alias($path = NULL, $alias = NULL, $pid = NULL) {
  if(substr($alias, 0, 2) == "~/") //detect bad path
  $alias = '~'.substr($alias, 2); //remove slash

I'll have to try it, but if it works, could be introduced in the subdomain module?

finex’s picture

The hack is not correct, the right code is:

function path_set_alias($path = NULL, $alias = NULL, $pid = NULL) {
  if(substr($alias, 0, 2) == "~/") //detect bad path
  $alias = substr($alias, 2); //remove slash

We don't have to add the tilde before the alias :-)