Skip Navigation

[Closed] Name of relationship post alongside Post Title in pre-selected form field

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 12 replies, has 2 voices.

Last updated by Luo Yang 1 year, 6 months ago.

Assisted by: Luo Yang.

Author
Posts
#2616145
w-company.png

I'm building a small CRM for my company.
I have the custom post type COMPANIES which stores the details of associated companies.
I have the custom post type INTERVENTIONS which stores each goal to be achieved with a specific COMPANY.
Each INTERVENTION is made up of several company visits.
So
1 to many relationship between COMPANIES - INTERVENTIONS
1 to many relationship between INTERVENTIONS - COMPANY VISITS

When I insert a company visit where I have to select the post to which it refers (therefore not in the case in the add form is reached from a child link, in which case the parent post is selected automatically by Toolset) I would like to show the title of the intervention and next to it the name of the company to which the intervention refers to, as shown in the w-company.png image.
How can I achieve that? Thank you in advance

#2616337

Hello,

In your case, it seems you need:
- One "company" post can connect multiple "intervention" posts
- One "intervention" post can connect multiple "company" posts

You can try many-to-many relationship between "company" and "intervention" post types, see our document:
https://toolset.com/course-lesson/many-to-many-post-relationships/

If you still insist on two one-to-many relationships, here is a sandbox website:
hidden link

1) Two post types:
hidden link

2) Two relationships:
hidden link

And describe detail for the question:

I would like to show the title of the intervention and next to it the name of the company to which the intervention refers to

Where and how do you want to show the title of the intervention and next to it the name of the company?

I need to test it in a live website.

#2616383
company name.png

Hi Luon,
I set up the environment as I need it, in the sandbox website you provided.
I cannot try many to many relationship because one intervention belongs to one company only, while one company can have more than one intervention during a year.
IN the website you provided you forgot one piece of the puzzle, which is company visits, that is the focus of the problem.
If you visit the website now you'll see a list of companies. If you click on one company you can view details of that company and a list of interventions initiated for it. IF you click on one intervention it takes you to the page details, with a list of company visits for that intervention.
Clicking on the Add New Company Visit button at the bottom of the page, will take you to the add company visit form, where the parent intervention is already set, as I created a child post link. I would like for the COMPANY NAME for which the intervention refers to, to appear near the intervention, so that the person who is entering data is sure to be referring to the right intervention for the right company.

#2616877

Thanks for the details, I am checking it in the sandbox website, will update here if find anything

#2616881

I have done below modifications in the sandbox website:
1) create a content template "interventions-information":
hidden link
Display it's parent company post information:

[wpv-post-title item="@company-intervention.parent"]

2) Edit the post form:
hidden link
add a HTML element:
a) You can display the parent_intervention_id URL parameter:
[wpv-search-term param="parent_intervention_id"]

b) And use above shortcode to display the content template:
[wpv-post-body view_template='interventions-information' item='[wpv-search-term param="parent_intervention_id"]']

Test it in frontend:
hidden link
It works fine

#2617377
how-it-should.be.png
add-company-visit.png

Hello,
I am sorry but that's not what I had in mind... It kind of works if you are on the INTERVENTION page and click on Add New Company Visit (although I'd like it to be shown differently). I tried adding a new company visit from the menu and it's not showing anything (add-company-visit-png). I need the company name to be alongside the name of the intervention (how-it-should-be.png).
Hope I managed to explain more clearly this time.

#2617493

Unfortunately, there isn't such kind of built-in feature within Toolset plugins, in order to get the grandparent "COMPANIES" post information, you need to parent "INTERVENTIONS" post ID as URL parameter, and need to setup the child post form link by following our document:
https://toolset.com/course-lesson/selecting-parent-posts-when-using-forms-to-create-child-items/

#2618899

Hello,
would it be possible to have a practical example on the sandbox site?

#2618911

It has already been setup in sandbox website, you can try these:
1) Login with URL:
hidden link

2) Go to one of single "interventions" post, for example:
hidden link
click button "Add New Company Visit":
hidden link

You should be able to see the grandparent company post title "COMPANY A"

Can you confirm it? thanks

#2619081

Hello Luon,
yes, I can confirm that. However that is just part of the solution.
What I asked was for the COMPANY name to appear ALONGSIDE the name of the intervention in the dropdown menu when you select "add new COMPANY VISIT" from the main menu, NOT after having selected the intervention. In your message you are guiding me to select a specific intervention, while I am asking to have that information available when clicking on ADD NEW COMPANY VISIT from the main menu. The reason why is that if someone is already on the company page, they already have that information. However, if I try to select an Intervention from the dropdown menu, seeing just the words "New Associate" doesn't tell me what company the intervention refers to. Now that there are just two or three interventions, its no big deal. When the interventions become 100, not knowing what company each of them refers to, becomes a big problem. Hope it's more clear now.

#2619227

As I mentioned above, there isn't such kind of built-in feature within Toolset Forms plugin.
You will need to pass parent "interventions" ID as URL parameter, so you can consider these:
In the "Add Company Visit" page, display a post view with custom search form:
- Query "interventions" posts
- Display the child post form link

#2619261

Ok.
Can you give me time to copy whatever code I need to study from the sandbox site before you delete it?
I am in the hospital right now and cannot work on it

#2619287

OK, I have updated this thread as "Waiting for feedback" status, you can update here if still need assistance for it, and you just use need to use the sandbox website login URL one time every day, so the sandbox website will keep alive:
hidden link

The topic ‘[Closed] Name of relationship post alongside Post Title in pre-selected form field’ is closed to new replies.