Navigation überspringen

[Gelöst] Postype relationship and placeholder

Dieser Thread wurde gelöst. Hier ist eine Beschreibung des Problems und der Lösung.

Problem:
How to send notification with data about currently manipulated post but also its related posts, in a Toolset Form?

Solution:
You can use a View that queries related posts to the one set in the ShortCode attribute XYZ, then complete the View with the information you want to send and insert the view to the form notification passing the proper ID in the ShortCode Attribute you choose, using %%POST_ID%% placeholder of Toolset Form

This support ticket is created vor 5 Jahren, 4 Monaten. There's a good chance that you are reading advice that it now obsolete.

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
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Dieses Thema enthält 13 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von Pat vor 5 Jahren, 4 Monaten.

Assistiert von: Beda.

Author
Artikel
#1339705

Pat

Hello,

I have defined a relationship and wants to retrieve in the placeholder of the Cred mail notification, some custom fields depending of the post chosen inside the relationship.

Let say room is a child of stage
Inside room, I have several custom field :
- address
- phone

I have a Cred form that is used to create inscription for a stage. That means the stage will be defined chosen in this form. As room is a child of a stage, I should be able to recover the needed info (address and phone).
Is it possible to get this in a placeholder and how?

Regards
Pat

#1340327

Can you try to create a View, that queries the Post type of which you want to send fields in the Notification, and set a Query filter to return only posts that are related to the post in the loop?

Then, insert that View in the mail notifications where you manipulate the related post, this should then produce the correct list of related posts in your email.
Now you can simply edit that Views loop so it returns only the fields of those related posts in the format you want.

Does this work on your end as well?

#1340847

Pat

Hi Beda,

Thanks for your support.

Just tested it and have an issue : in fact, I'm not using the Views inside the product

My configuration is the following :

Relationship between Product and Room
Relationship between Product and Inscription
I have a use Views in which I display a Cred to create an inscription. In that Cred, I have a field to chose the Product. Then, I want to retrieve inside the Cred mail notification the fields related to the Room

So, its a little more complex.
Any idea?
Regards
Pat

#1341787

Well, that is a lot of edges.

This will not work fine, because the related post is related over 2 different steps.
You would need to pass the chosen post (product) ID to the URL, then catch that in the View as a URL parameter and display the Rooms related to it, in your notification

But Views is not intended to be used like this, basically.

I suggest taking another approach.

The information that is sent in a Toolset Form should be related to the Post edited or created.
If that information is from "too far away" (other posts, etc) it may be needed to put the information directly in this very post type instead of the other, related one.

Maybe, it will help if I can see what you have built in the backend, so I an wrap my head around the actual issue better and maybe suggest another solution?

#1341817

The password is wrong, so the login screen tells me

Can you re-send it?

#1341859

Pat

Hi Beda,

Thinking again on this issue, perhaps the best way would be to manage the admin "INSCRIPTION" differently. The Cred form is currently integrated inside the user display page, but we could place it inside the product page (and give the admin the choice to define the right user ?)
This should make the process easier and also, use the same way of doing for admin and user buy process.

Regards
Pat

#1341861

Yes, this worked.

I see that all your Toolset Plugins (and others) are out of date, and would like to suggest first updating all software so we can speak of the same features/locations where to achieve things.

I think you mean the Post Types Salles, Inscriptions and Products, in a relationship with each other, right?
When a new Inscription is added, a product is chosen as related.
In that notification you want to send data of the related Salles (related to the Product chosen)

Is this correct?

Since you are currently editing Forms on the page I cannot even look at it in the backend, it asks me to take over, but if I do so I am redirected to pages and cannot see the Form still.

If you need me to have a look at the backend and make examples, I need to be able to edit everything related to this.

Thanks.

#1341875

OK, our replies crossed, I am now replying to https://toolset.com/forums/topic/postype-relationship-and-placeholder/#post-1341859
However - it's not related to the topic, it's about where to display that form, which basically does not matter (yet) to the task.

Can you let me know about https://toolset.com/forums/topic/postype-relationship-and-placeholder/#post-1341861 when you are ready?

==> Note, maybe it's better to use a staging site, so I can make a few tests while you can proceed working on the current site.

Thanks.

#1341877

Pat

Hi Beda,

You're right on the way things must work.

In the meantime, I have launch the plugins update. I have disconnected myself so you should be able to manage everything now.
Regards
Pat

#1341905

Pat

Beda,

Concerning https://toolset.com/forums/topic/postype-relationship-and-placeholder/#post-134186, I'm OK with what you have said :
I think you mean the Post Types Salles, Inscriptions and Products, in a relationship with each other, right?
When a new Inscription is added, a product is chosen as related.
In that notification you want to send data of the related Salles (related to the Product chosen)
=> correct

For the stagging site, I have no time to prepare anything else in the short term. So, my proposal is that ou duplicate what you need to modify in order to be able to come back if needed?

Regards
Pat

#1341971

Our Support policy does not allow me such full stack development, including duplications and tests including ready solutions.

What I can do is either set up some example on the site, or instruct you how to do it.

I think I may have a solution - which works locally, but that's a limited playground.
It's based on this workflow:
https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/displaying-fields-of-grandparents/

You can create a View, that displays products.
Choose to display products as related to the Current post in the loop.
In the Loop, display related Rooms using the item attribute, like explained here https://toolset.com/documentation/user-guides/views-shortcodes/item-attribute/, and in some steps here too https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/displaying-fields-of-grandparents/.

That View now displays Rooms related to the Product that is related to the in the loop, so if that View would be inserted in a Inscription Post it'd show the rooms related to it through the product(s)

We will insert it in the Notification of the Form that manipulates the Inscription, which is related to the Product.

That should work, when you now submit the Form for a new Inscription, pick, an existing Product as related, and submit, the View will gather the related Product to the current post in the Loop (the Inscription), and then display the Room related to that.
Room Info can be displayed wether it is native (title) or post fields.

Does that work on your end as well?

#1343141

Pat

Hi Beda,

Not sure this will be sufficient.
Concerning the admin management of "Inscription", let's consider a page. In this page, we have a Views that display all info from a specific user (the user id is defined by the url filter).
Then, in this Views, we have the Cred form (Inscription). In this Cred, we have the ability to chose a product thanks to a generic field (a Views is used there to list the products and placed inside the generic field options).

So, as we are not on a product page, I'm not sure your solution could work as the product is only defined when the selection is made thanks to the generic field.

You still have the rights on this site and you can have a look if you need more detailed info.

Regards
Pat

#1343687

Well, but with a generic field you will not setup post relationships.

Please explain to me how this is related to a relationship - with generic fields we are supposed to add data that will not survive the form, so to say, because they are intended for example to generate bases for Form conditions, and only with legacy support they can persist to the database.

Only with (complex) custom code that I do not see mentioned it would be possible to actually connect posts thru a generic field.

However, it does however not really matter wether you are on a product page or not, and ignoring the detail about relationship for a moment, you can still get all the posts that should come from that View in a Form notification, even if that form is not on a single post.

You can set the View to listen to a ShortCode attribute to get the Post ID to which of get the related posts.
Then insert that View in the Notification passing the ShortCode attribute you have set completing it with %%POST_ID%% placeholder Toolsets Forms offers.
That placeholder is the id of the post manipulated, no matter if in a view or not, because it is coming from the form.

So if we pass it to the View, that View will now get posts related to the post passed with the placeholder.

However, That view will not return any related post, if those are not setup with the Toolset Post Relationships (which does not include generic fields, per se)

But unrelated to that, the View will respond to the Post ID you passed in it and hence return the (if existing) content.

#1343959

Pat

Hi Beda,

Even if I was not fully convinced by the solution, I tried it and IT WORKS !!!

Many thanks
Pat