1

I am using the Rules module to create some default group content upon creation of an organic group. The rule is copied below and works well except that the url pattern for the default content is not being generated as I want it to be.

I would like url pattern to be [node:og-group-ref]/content/[node:title] and I have this working for regular group content which is created manually once a group exists.

The problem is that default content created by rules is missing [node:og-group-ref] in the url. If I edit the generated content I see that the setting to 'Generate automatic URL alias' is unchecked. If I then enable this and re-save the url ends up as I need it.

And I am guessing that pathauto is not aware of the og-group-ref value when the node is first created by rules and can not use this token.

I have tried including an action to create a url in the rule, but this seems to get overriden by pathauto.

So my question is - How to set the url alias of a node created by Rules?

{ "rules_og_create_group_content_timetable" : {
"LABEL" : "OG Create group content - Timetable",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"REQUIRES" : [ "rules", "og" ],
"ON" : { "node_insert--og_group" : { "bundle" : "og_group" } },
"DO" : [
  { "entity_fetch" : {
      "USING" : { "type" : "node", "id" : [ "node:nid" ] },
      "PROVIDE" : { "entity_fetched" : { "entity_fetched" : "Fetched entity" } }
    }
  },
  { "entity_create" : {
      "USING" : {
        "type" : "node",
        "param_type" : "og_page",
        "param_title" : "[entity-fetched:title] Timetable",
        "param_author" : [ "node:author" ]
      },
      "PROVIDE" : { "entity_created" : { "entity_created__page_stub" : "Created entity page stub" } }
    }
  },
  { "entity_save" : { "data" : [ "entity-created--page-stub" ], "immediate" : "1" } },
  { "og_group_content_add" : {
      "entity" : [ "entity-created--page-stub" ],
      "group" : [ "entity-fetched" ]
    }
  }
]

} }

0

It is probably because you have not "made that field available yet to Rules".

To do so, add a "Rules condition" like "Entity has field", and use that "[node:og-group-ref]" in that condition to be added.

Not sure if it is the ONLY problem you have, but for sure something you should add to your rule.

  • [node:og-group-ref] already seems to be available. It is as if the node is created but then pathauto is setting the path as per it own rules. – MrPaulDriver Nov 22 '15 at 18:02
0

I am not sure how to get PathAuto and Rules to work together, but you can set the Title of the node you are creating in Rules before saving it (set it to the same tokens you are using in PathAuto, but make sure they are all available in your rule, renaming as necessary). The danger of this approach is that if you change the PathAuto title string for your node then you also have to update the rule, and if you forget, then you will have content generated with two different passwords.

However, if it is highly unlikely that you will be making changes to the alias later, this is a reasonable approach.

  • Thank you Patrick. You are correct about the title, but I really need a group specific path. – MrPaulDriver Nov 22 '15 at 17:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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