Skip Navigation

[Resolved] Nested view: child post – parent post – child post

This support ticket is created 3 years, 10 months ago. 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
- 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/Karachi (GMT+05:00)

This topic contains 6 replies, has 3 voices.

Last updated by Lara 3 years, 10 months ago.

Assisted by: Waqar.

Author
Posts
#1668901

Tell us what you are trying to do?

I am trying to create a nested view: Page: My Account - child post - parent post - child post
The parent post has different child posts. The last child post needs to be the same child post like the first child post.

Why? The parent post is an offer, that people can sell. If they don't wanna buy for the offered price, they can suggest a new price through creating a child post/repeating group field. The name of the child post / repeatable group field is negotiation. As soon as the negotation is over, they need to submit an CRED EDIT FORM, that edits the offer post and switchs a selected field from "not sold" to "sold. Here comes the problem: The same EDIT FORM also needs to edit the price field. Instead of the originally price it needs to change to the newly negotiated child post price.

Structure:
-- VIEW Child post negotiation
------ VIEW with parent post, because I can't insert the EDIT FORM of the parent post in the child post view
--------- EDIT FORM parent post
-------------- I tried to get the childpost price through [types field='negotiation' item='@negotiation.child'][/types]. The problem is that it outputs always the price of the first child post. For example a parent post has four negotiation child posts. Every time the [types field='negotiationprice' item='@negotiation.child'][/types] outputs the value of the first negotiation child.

As a workaround I came up with the idea to use a child post view, that only contains the [types field='negotiationprice' ][/types] field and will be inserted in the same position, where the [types field='negotiationprice' item='@negotiation.child'][/types] is now.

Therefore I need the: My Account Page - child post A - parent post with eg 4 childposts - child post A ----> where both child posts are the same.

Is there any documentation that you are following?
no

Is there a similar example that we can see?
no

What is the link to your testsite?
e-bywood.agentur-mediax.de

#1669437

Hello,

I don't think you need such a complicated nested view.

In your case it needs just one post view (VIEW Child post negotiation) + one edit post form "EDIT FORM parent post" + one content template.

For example:
1) Create a content template "edit-parent-post", display the edit post form: "EDIT FORM parent post"
2) in loop of the post view (VIEW Child post negotiation), you can:
- Display negotiation field value of current child post with shortcode:
[types field='negotiation']
- Display the edit parent post form with content template shortcode:
[wpv-post-body view_template="edit-parent-post" item="@negotiation.parent"]

More help:
https://toolset.com/documentation/user-guides/views/views-shortcodes/item-attribute/
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-post-body

#1669537

Many thanks Luo, this sounds awesome to me.
I will try it later and let you know.

Kind regards
Lara

#1669999

Hi Luo,

#1: Display the edit parent post form with content template shortcode ---> this works great now. Thanks 🙂

#2: There is still the problem with the EDIT Form. I added the code below. As you can see the parent field "priceoffer" needs to have the value of the child, which is currently displayed in the view loop. Somehow there seems to be a problem with the setup. Instead of the current child value it shows the value of the first child. Any idea what I am doing wrong?


[credform]

<!-- ---------------------------------------- HIDDEN FIELDS ----------------------------------------- --> 
<div class="bt-hiden">
[cred_field field="priceoffer" force_type="field" class="form-control" value="[types field='negotiation' item='@negotiation.child'][/types]" output="bootstrap"]
</div>
<!-- --------------------------------------- END HIDDEN FIELDS --------------------------------- --> 

<!-- ---------------------------------------------- BUTTON ------------------------------------------- --> 
[cred_field field='form_submit' output='bootstrap' value='Buy' class='btn-angebot-kaufen']

[/credform]

#1672129

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi Lara,

Thanks for the update.

Luo will be on vacation this week, so I'll be following up on this ticket.

To troubleshoot this in more detail, I'll need to see how this edit form is set up in the admin area.

Can you please share temporary admin login details, along with a link to a page where this form can be seen?

Note: Your next reply will be private and please make a complete backup copy, before sharing the admin access.

regards,
Waqar

#1674919

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi Lara,

Thank you for sharing the admin access and these details.

The challenge here is that the view "MEIN ACCOUNT | Item ---> Wo ich verhandle" clearly specifies which "Verhandlung" post is needed through the "Query Filter" settings.

But in the form "Verhandlungsangebot annehmen & Kauf abschließen", when "[types field='verhandlungspreis' item='@verhandlung.child'][/types]" shortcode is used, it translates to get price field from any child "Verhandlung" post and it gets it from the first available one.

To overcome this, you have two options:

1. View approach:

You can create a new view with similar query filter settings as the "MEIN ACCOUNT | Item ---> Wo ich verhandle" view.

The only difference is that this new view will only return the ID of the required "Verhandlung" post and nothing else.

That ID can then be used inside the form "Verhandlungsangebot annehmen & Kauf abschließen" to get the price.

2. jQuery approach:

You have access to the desired "Verhandlung" post's ID and the price field in the loop of the view "MEIN ACCOUNT | Item ---> Wo ich verhandle".

You can wrap the shortcode for the content template in a special div container that includes the values of that post ID and the price as data attributes.

Example:


<div id="form-container-[wpv-post-id]" class="form-container"  data-id="[wpv-post-id]" data-price="[types field='verhandlungspreis'][/types]"> 
[wpv-post-body view_template="edit-angebote-im-wo-ich-verhandle-view" item="@verhandlung.parent"]
</div>

This will allow you to get the post ID and/or price using some custom script, on-the-fly, and then show and/or fill it in the desired field.

I hope this helps and please let me know if you need any further assistance around this.

regards,
Waqar

#1677693

Thanks Waqar, the probelm is solved.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.