Drupal 10 and Group module: using Views to list entities and relate to a field in the Group membership plugin - drupal

I'm stuck with something I'd like to achieve using Drupal 10, Views and the Group module.
The point is to have a website allowing parents (Users) to create a family (Group), add children (Nodes), then add expenses (Nodes) linked to a specific child.
To achieve this, here's what I've got:
I've got a Group type called "family"
the Group Membership plugin for this Group type is installed and has a field of type Number called "percentage" (which allows parents to specify which part of the expenses they'll take in charge)
Drupal users who are members of a "family" group are "parents"
I have a content type called "child"
and I have a second content type called "expense" with a reference field pointing at the "child" entities and an "amount" field
Now I created a View listing all expenses for a specific family, grouped by author (parent). This works quite fine.
What I can't figure out is how I can get the "percentage" field (which is in the Group Membership plugin) in order to display which part of the expense's amount the current logged in parent should take in charge (for each expense listed).
So instead of having a listing such as:
Expense : title, child, amount
I'd like to have:
Expense : title, child, amount, your percentage, your part (calculated)

Related

calling of one taxonomy from another taxonomy, so both of them have used in the same content type

Can we call one taxonomy term from another as a parent and child relation for example I need to click on product category and that show me product series page and when I click on product each series that will lead me to actual product detail means node, so I have two taxonomies category and series I am about to click on category to carry me to series page and then to click on series page to carry me to product detail page on the concern series”
no codebase problem
i am expecting that these two taxonomies may be used as i have mentioned in the question summary but, i can't do it so i hope some help in resolving this issue
Let's look at this answer, I hope it will help you.
Taxonomy terms from the same vocabulary filtered and referenced on multiple content types
To do this you’ll need to have the Entity Reference module installed. So get that out of the way quickly with drush dl entity reference -y and drush en entityreference -y if you haven't already.
First up, we need the taxonomy set up.
Let's demonstrate with the help of an image.
You’ll notice that these terms could be more or less grouped into two categories: Transport and Sleeping. One term (couchette) kinda fits both criteria and is there to exemplify the reason for not using 2 different vocabularies to handle the issue. Now we need to technically make the distinction between these terms as well and since they are entities, we can use a field for that.
So we can now go ahead and add a new field to this vocabulary of the type List (text) with whatever widget you’d like (and let’s call the field Type). You should make the allowed number of values unlimited and put the following in the allowed values list:
Edit each term and select the appropriate type. As expected, for the term couchette, you should select both options.
Now that we have our taxonomy squared away, it’s time to create a View that will handle the filtering of these terms. Because if we now add the Tags taxonomy term reference field to our content types in the normal fashion (as it is already present in the Article content type) we’ll be able to select all the terms in the vocabulary for all the content types. And that's not what we want now.
So create a drupal 7/8 View that shows taxonomy terms of the Tags vocabulary - let’s call it Tags Filter. Add 2 displays of the type Entity Reference and a filter of the field we added to our terms earlier. So for instance the first display can show the terms which have Sleeping selected and the other one can show terms which have Transport. Save the View and you can close it.
Now finally we can edit our content types and add to each a new field of the type Entity Reference with a select list widget. For the target type select Taxonomy term and under Entity Selection choose the following: for Mode, go with Views: filter by entity reference view and then select the View in question - one of the two displays which we created earlier. In the picture below, I named one of the displays

Make Drupal 7 Group by always show grouping field

I have a Drupal 7 view similar to the one described here: Drupal 7 Views - list group by field
I wish to have all the groupby fields always appear even if there are not members of them and ideally I wish to put a default value in such a list.
eg:
Foo:
-Jay
-George
Bar:
-Barry
Boo:
Sorry no entries at this time!
Suggestions?
If none of what you are fetching with the view is associated with the group 'Boo' then the view doesnt know it exists, so would never be able to show it but say there is no results for it.
What i would recommend is creating a taxonomy vocabulary with the terms: Foo, Bar, Boo.
In whatever content type your names belong to, create a term reference field, and link them to the terms.
In the view, fetch the taxonomy terms, create a relationship to the content type that references the taxonomy, and pull those through based on that. There is a setting in views for multiple results to combine into one field (so you would want to do that). Then you could add the 'Sorry no entries at this time!' as a field's no results text.
So to recap: VIEW => TAXONOMY TERMS => NAME CONTENT

How to add additional field to drupal organic group 'User and Group' relation?

Im using Drupal Organic group module and I want to create a group and need to assign users (filter by perticular role) to that group. I have done that part easily but the problem is that, I need to add aditional note on per each group user relation.
Lets say there is a group called "School Prefects" and need to add users to that group whos role is student. In here I need to put a small description for each relation.
Please help me to figure this out.
Thanks in advance.
I will probably deal with the same problem soon.
I think a possible workaround is to use the relation module and
the rules module. You could set up a rule to create a relation
each time a user is assigned to a group, or something like that.
Relations made by the relation module are fieldable. But it would be
maybe better to add a field to the og user-group relation directly.
Update: now that I tackled the issue, I have a different solution. We don't need to add new relations, the og_membership shipped standard with og is all that we need. This is how I did it.
I created a new membership type from admin/config/group/group-membership. It's a fildable entity so I added the required fields: in your case it will be "description".
Then I changed the used membership type per user, I did it in admin/config/people/accounts/fields/og_user_node (I needed to change the field "group membership" in user account).
So, now when you (or a group administrator) go to "manage group page" (clicking the group tab in group node), where you can add new people or manage members, either way you can edit your custom field "description" on each membership users-group.
Besides, you can clone the "og members" view adding the field "description", so in people panel in the group homepage we see name + description.
I my use-case I had to see (per group member): name, role, start date, end date. E.g. John Doe, president, from 1997 to 2003.

How do I get Group ID as context in Views Drupal 7 without Panels

I have been banging my head all day with this. I have seen other posts, but they all seem to say "Use Panels" and I dont want to make a panel page for every view.
I am using Drupal 7.x, Organic Groups with Group Context, and Views.
I created a content type as a Group, and several content types as Group content types.
In my view, I added the relationships Group Membership:Node group membership, Group: Node, and Content:Author. I have tried various Contextual filters, but none seem to be working.
The view is display type page, with a path of node/%/content/documents (documents is the content type where I want to show all uploaded documents for a particular group).
What is see is whenever I add a contextual filter, the query contains a line similar to WHERE ((og_node.gid = 'xx')) and the value there is the value of the group node entity ID, and not the GID. I have set the default value on the contextual filter to "current OG Group from context" and I have set the validation criteria to validate on the Content ->group content type, and Node ID. I can get the Page Display title to use the %1 placeholder to accurately grab the Group Node title successfully, but I cant get context to be passed in so the WHERE clause contains the GID and not the entity id.
Any help?
I just tried this and the following two settings worked for me:
Relationship of Group membership: Node group membership
Contextual filter of (group membership) OG membership: Group gid
In the preview window, when I enter in the gid for the contextual filter, I get back exactly the nodes belonging to that group that I expect.
Have you tried that one yet?
You can try the og_context module (part of og)

In Drupal 6 how do i automatically create CCK fields on a node when a new node of a referenced node type is created?

I'm using Drupal 6 and Views 2, along with CCK, Panels and Node Relationships. (so far)
I have two basic content types defined:
User Profile (using Content Profile module)
Product
Each of these content types has a node reference to two other content types, Tier and Commission:
User Profile content references "Tier" content
Product content references "Commission Category" content
There may be 5-10 of each of these, and up to 100 of each of users/products.
When a Commission Category is added, dollar values need to be added for each currently existing Tier node.
When a Tier node is added, dollar values for this Tier need to be added to each currently existing Commission Category node.
The desired effect is that users with a "staff" role can administrate both Tiers of users and Categories of Product.
Users will see a value when they view a product that is displayed as a combination of both their Tier and the Commission Category.
For Example:
Category A => Tier 1 ($100), Tier 2 ($200), Tier 3 ($300)
Category B => Tier 1 ($120), Tier 2 ($250), Tier 3 ($300)
Is there a way to do what I'm suggesting? or do I need to try a different approach altogether to achieve the desired effect?
I assume that you also want to be able to later edit those amounts from either the Tier node page or the Commission Category node page.
To make those values easier to manage, you will probably need to create another content type (called Commission for example) which references a Tier and a Commission Category, and holds a dollar value.
What I would do then is to use hook_form_alter() so that in the Tier form, an input field is added for each Commission Category. That way, whenever you add a new Tier (or edit an existing one), you can update all those values at once. Use hook_nodeapi() to insert/update all of the corresponding Commission nodes.
Then you can do the same thing for the Commission Category form, but in the other direction.
If you expect to have a large number of tiers or categories, this may be a heavy operation, but otherwise it should be fine since I'm assuming you wouldn't be changing these values that frequently.

Resources