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

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.

Related

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

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)

Creating view with node reference

I am using drupal 6. please give me idea about how should i create view with below requirements,
There will be list of awards (gold , silver etc)
There will be list of companies who won one of the above award (comp1->gold, comp2->gold, comp3->silver etc)
I need to display list of awards first and when user clicks on any award he will be redirected to page having list of companies who won that award.
I created two content types for Awards and Companies and award_id is used as node reference in Company content type. Please guide further.I am using drupal 6. Thanks.
Fist task (just a simple list of awards is easy - just create a view that displays nodes in "awards" type, order as you want, limit as you want...
Get also node id filed, if it's not available at start, since you gonna need it.
For the second task - create a new view, that will list companies and under arguments add that award id. Then, you should pass award id to page as extra parameter:
/awords/3
Where 3 is award id.
Sorry, Drupal 6 is pretty old and I didn't use it lately, but that's the basic idea.

Drupal Profile2 / Field collection sorting records

As continuation of this article Drupal nested / complex / sub content types I have a new question.
As described, using Profile2 and Field collection I've managed to create multi-user CV management system:
Created a content type called CV.
Added a field_collection field to CV called education and allow unlimited entries.
Edited the education field_collection item and add a date field and a text field.
Did the same for work experience and any other fields.
Unfortunately, users should be able to reorder the records (date-text), e.g. to put some of the entries before others. For the moment being they appear in the order of their input.
How to achieve that?
Thank you!
The image below shows a field collection I have made with 3 fields.
One the left of each collection item is a drag handle.
You can re-order content using these handles.

Drupal 7: Search fields

I've just started to learn Drupal and decided to implement a simple "Student list" site.
In my content type "Student" I have added a numerical field "age". And now, after entering some content and reindexing I want to perform search on the "age" field.
If I enter some valid age into search box, then nothing is found.
How do I find students by age or by age range?
If you're new to Drupal, each of these steps will require its own instruction. Luckily, there are plenty of tutorials on the interweb.
To create a sortable/filterable list page from your student content type:
Create a view from the student content type.
Set the new view's display type to Table View and ensure that the the age colum is listed as a field you want to display.
Set the table's headers to clickable (so that you can sort your list when it's displayed.)
Use exposed filters to allow people to filter your group by an age, age range, or other criteria (e.g. last name, etc.).
I'd consider the following searches for each step:
Drupal 7 Create View site:youtube.com
Drupal 7 Table View Display Format
Clickable Table View Headers in Drupal 7
Drupal 7 Exposed Filter site:youtube.com

Drupal 6: creating location list manually or dynamically via cms

I'm starting my first Drupal project, pretty excited :) I have a question;
the project is a hotel directory site. at sidebar I have locations list (London, Manchester, Liverpool, etc..) and filter the hotels related on location click.
So, how should I create these cities? Should I put them manually and give links manually depending on location id? or is there any better way to create this location list and linking filtering dynamically (via cms, or custom module, etc...)
Appreciate advices!!!!
This would be a good example of when to use the core (part of the base Drupal software) Taxonomy module. With Taxonomy you can set up one or more lists of terms that describe some or all of your nodes. For example, you can have a list of locations, a list of amenities (pool, sauna, golf course, etc.), and a list of price ranges (low, medium, high).
For each hotel you can select a location from the locations list, one or more amenities, and a price range. Then you can select all of the hotels that match one of the lists, using a neat feature of Taxonomy where it will return a list of those nodes.
The lists of terms are called "Vocabularies", and you'll want to create a vocabulary for each list. Go to Administer -> Taxonomy -> Add Vocabulary. Give it a name, like "Location" a description if you'd like, and choose the content types that it should be allowed to be associated with. (In your case, the hotels should probably be a custom content type that is different from the Page and Story types, but for trying this out, just pick Page for now.) There are several checkboxes at the bottom to decide on: Don't check Tags or Multiple Select, as these allow free tagging by users (images users making up city names) and also allow a node to have multiple locations. Do check the Required checkbox, as each hotel should have one.
Click Save and then click Add Terms on the vocabulary list page, and add a few locations. Then create a few hotel nodes (Pages for now) and you'll see that there is a new section in the Create Content page that is a dropdown selector that contains the locations. Choose one for each hotel, and add a few hotels in the locations that you just created.
To select the hotels for a given location, you will need to know the path associated with each term. Go back to the Taxonomy admin page and choose List Terms for the Location vocabulary. On the Terms in Location page you can get the list of hotels for a location by clicking on a location's name. The resulting page's path (e.g. example.com/taxonomy/term/2) would be what you'd use in your menu for that location. Each location will have its own term number that would be at the end of the path.
This is the simplest way to use the Taxonomy module, but it works really well with other modules like Views. Using Views you can control the format of the list of hotels for each location.
For more information, see the Taxonomy documentation and especially this sub-page called About Taxonomy.

Resources