One big missing part of the Group module is setting up friendly URLs that contain the group in the path for group content. You can't set this up in Pathauto -- the tokens are too limited to handle this correctly. There is an issue to make this work for group, but it's currently marked "needs work". There is also a module to provide a token, but it has not yet been updated for Group 3. Both of those approaches simply make it so you can insert a token pattern in Pathauto to include a group in the path.
Group Purl essentially does this automatically without using Pathauto -- and it provides a few other helpful benefits:
- Views Contextual filter - use the current group context as a filter on your views. This is extremely useful when you want to set up per-group views -- if you add this filter, you can use the same view for all content or just content within the group.
- Condition plugin - the block layout system uses these to show or hide blocks in particular conditions -- when a path is active, for a specific content type, etc. Now you can show or hide a block within a particular group, or in a group, or only not in group. Condition plugins can also be used in other code.
- Menu Link context - the PURL module can add a "PURL context" section to menu link items, which adds options Group Purl uses when these links are rendered. The options include exiting the group context (always remove group paths), keeping the group context (if you're on a page in a group, include this group in the path), or going to a specific group context (e.g. a link to a page in a "Police" group that you want visible on all pages). This allows you to link to one view with different group contexts.
To set this up on your Group 3 site:
- Install PURL with D11 patches applied (or version released with full D11 compatibility) and enable.
- Install Group Purl 3.x and enable.
- Under Admin -> Configuration -> Search and Metadata -> Persistant URLs, add a PURL Provider using the Group Purl Provider plugin, and Group Prefix method. (Group Subdomain at this point is completely untested).
- Set up Pathauto for your group entities -- Group Purl uses the alias set for each group as the prefix URL. You can see what is defined on the PURL Modifiers page.
- For each content type or entity type/bundle that you want to have the group context added, edit the content type (e.g. Admin -> Structure -> Content Types -> Basic Page -> Edit), and in the PURL settings, and select "Keep context of the node." With this active, URLs Drupal generates for this node will include the group path!
Caveats
There is also a subdomain prefix method in this module, but that isn't currently tested for all the recent changes to this module. Merge Requests are welcome, or contact us if you'd like our assistance fleshing this out.
Next up: automatically adding content to a group, when a group prefix is active. You'll notice when using this module, if you are in a group with a modifier of "safety", all of the admin links preserve that prefix -- so when you follow a "Create article" link while you're in that group, you'll be taken to /safety/node/add/article. When saving the post on that URL, it should automatically add the new content to the group. "Should" as in that would be what I expect as an editor -- it doesn't yet. The easiest way to implement this today would be to create an ECA Condition plugin to check for a group context, and an Action to load it -- and then you could create the appropriate group relationship entity to add the content to a group.
Add new comment