In pathauto module settings I have

localhost/[node:group_group]

for all group types. I have few group types: Ex Technology, Arts, Design etc and within each group type you can create as many groups as you want.

So when I create a group named google, the path looks like this :

localhost/technologies/google

.

I want to have any article created within that group and to have a path like this

localhost/[node:group_group]/[node:title]/[content-type]/[title]

Ex:

localhost/technologies/google/article/some-article

How to achieve something like this? I could not find any token replacement pattern for my use case in pathauto module. Is there some trick here?

Thanks

I tried:

[node:og-group-ref:url:relative]/[node:menu-link:parent]/[node:title]

Worked like a charm.

So, I guess that you should go with:

[node:og-group-ref:url:relative]/[node:content-type]/[node:title]

Note: Posted the answer since this was the first result on Google (for me), and no answer was given... Perhaps it will put someone else in the right direction faster.

[node:og-group-ref]/[node:title] is what worked for me.

  • Note that [node:og-group-ref] will result in a URL chunk based on the actual name of the group. This can differ from the group's URL alias if you configured a manual alias there. If you want the group's URL alias, the answer by @Marcus Farrington points into the right direction ... – tanius Sep 19 '14 at 14:45

this isn't a complete answer as I only have one group type ("projects"), but within admin/config/search/path/patterns I use

projects/[node:group_audience]/[node:content-type]/[node:title]

for each of the different content types, unless I want the url to display a different term than that of the content type. I believe this would cover the

google/article/some-article

part of your string. Presumably you'd just put your

[node:group_group]

in place of my "projects," unless [node:group_group] produces "technology/google," in which case go with

[node:group_group]/[node:content-type]/[node:title].

  • Thanks, however [node:group_group] is not recognizable when the path is for a group content type. That is, an article path in pathauto doesnot recognize [node:group_group]. And that is how it is suppose to be. I could hardcode something like you said technologies/[node:group_audience]/[node:content-type]/[node:title], but in that case I have to create article content type for each group type. And thats a bummer. – Minty Jul 13 '12 at 12:17

For me, this worked:

  1. Install sandbox module og_token.

  2. Apply patch og_token-og_7.2-1930132-1.patch to og_token, as per Drupal issue #1930132 comment 1.

  3. Optionally, if you want the tokens to use the group's URL alias rather than group title: in file og_token.module, exchange function og_token_get_group_labels() with this:

    function og_token_get_group_labels($nodes, $options) {
      $labels = array();
      $sanitize = !empty($options['sanitize']);
    
      foreach ($nodes as $group) {
        $label = drupal_get_path_alias('node/' . $group->nid);
        $labels[] = $sanitize ? check_plain($label) : $label;
      }
      return $labels;
    }
    
  4. Set your pathauto pattern to:

    [node:og-group-audience:first]/[node:content-type]/[node:title]
    

This solution is based on lahode's work. It achieves the same effect as the answer by @Marcus Farrington to this very question, which for me does not work with the latest versions of modules og, token etc..

All these problems with OG tokens are discussed at length in Drupal issue #1088538.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.