Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide an example, how to use it on organic groups #1

Closed
schoenid opened this issue Mar 14, 2022 · 6 comments
Closed

Provide an example, how to use it on organic groups #1

schoenid opened this issue Mar 14, 2022 · 6 comments

Comments

@schoenid
Copy link

schoenid commented Mar 14, 2022

This is a question:

I'm trying to create an automatic selection of a group while creating a new organic group content.
The structure in HTML looks as follows:

- None - Erzähler-Gruppe Maler-Gruppe Musiker-Gruppe Tänzer-Gruppe

So I've created a view with the Content: Title of the group, I want to create new content in.
(Group node from OG membership) Content: Title
This gives me the groups title, if I'm on the groups page URL, as example "Erzähler-Gruppe".
Then I've tried to Rewrite Results for this field: "Create new book ..." and to output the field as a link:
Link path: /node/add/book?edit[og_group_ref][und][0][value]=Title

So this or something similar should open the book edit page (it does), but with marked group (it does not ...).
I've tried several possibilities and combinations, without success.

Link path: /node/add/book?edit[og_group_ref]=Title
Link path: /node/add/book?edit[og_group_ref][und][0][default]=Title
Link path: /node/add/book?edit[og_group_ref][und][0][default][value]=Title
Link path: /node/add/book?edit[og_group_ref][value]=Title
Link path: /node/add/book?edit[og_group_ref][default]=Title
Link path: /node/add/book?edit[og_group_ref][default][value]=Title
and more ...

Could someone help here, please?
Many people would be thankful.

Best Regards

@olafgrabienski
Copy link
Member

@schoenid Try to add the ‚NID‘ (Node ID) to the link path. It worked for me following the steps below.

  • Add a views block, content of type Group, Field: Nid, and rewrite the field to:
    <a href="/node/add/post?edit[og_group_ref][und][0][default]=[nid]" title="Add a post to this group">Add post</a>
  • Add a Contextual filter to the view: "Content: NID", Provide default value: "Content ID from URL".
  • Place the views block in the sidebar of the Group layout.

Does that work for you? (You need to adapt the example slightly.)

See also backdrop-contrib/og#45 (comment).

@schoenid
Copy link
Author

Great !!!

I'm using the following views configuration, to allow it to be displayed only in a group with valid membership:

RELATIONSHIPS

  • OG membership: OG membership from User account
  • (OG membership from user) OG membership: Group Node from OG membership

CONTEXTUAL FILTERS

  • (OG membership from user) OG membership: Group ID -> set to "Provide default value" and "Content ID from URL"

FILTER CRITERIA

  • User account: Active (Active)
  • User account: Current (Yes)

FIELDS

  • (Group node from OG membership) Content: Title
    Settings "Rewrite results":
    Text: "Create new Book ..."
    Checked: "Output this field as a link"
    Link path: /node/add/book?edit[og_group_ref][und][0][default]=%1

This works 👍

As I found further below in the field settings the "Replacement patterns" I was able to configure the view for different configurations of the Groups audience field:
For Lists: /node/add/book?edit[og_group_ref][und][0][default]=%1
For Checkboxes: /node/add/book?edit[og_group_ref][und][0][default][%1]=%1
For Autocomplete (Tags style): /node/add/book?edit[og_group_ref][und][0][default]=[title_1]

@olafgrabienski 👍 Thank you very much !!!

@laryn
Copy link
Member

laryn commented Mar 15, 2022

@schoenid Would you be willing to add a page to the Wiki with this information for others to find more easily?

@schoenid
Copy link
Author

@laryn Yes, I would do that, if I would have an edit permission. Unfortunately I don't have it.

@laryn
Copy link
Member

laryn commented Mar 19, 2022

@schoenid thanks! I think I just opened up the wiki to edits. Let me know if you still have trouble with it.

@schoenid
Copy link
Author

@laryn Thank you too.
I've created a detailed example, how to find and apply the correct settings to a view, for the creation of a new groups content, using Prepopulate, to fill in the groups association. I hope, everything is fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants