Skip Navigation

[Resolved] Toggle button in Group of Repeating Fields

This thread is resolved. Here is a description of the problem and solution.

Problem:
I have a view where is inserted another view with Group of Repeating Fields (as a child post). The view with child post has this code inside:

<button data-toggle="collapse" data-target="#obsah">VÍCE</button>
<div id="obsah" class="collapse">
[wpv-post-body view_template="None"]
</div>

If I click on the button nothing happens. If I place code for button into view for parent, it works. And after, how to secure that only the related post-body will show, not all of them?

Solution:
You will need to assign a unique HTML ID attribute for each div tag, for example, you can change the codes from:

<button data-toggle="collapse" data-target="#obsah">VÍCE</button>
<div id="obsah" class="collapse">

To:

<button data-toggle="collapse" data-target="#obsah-[wpv-post-id]">VÍCE</button>
<div id="obsah-[wpv-post-id]" class="collapse">
This support ticket is created 7 years, 1 month 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/Hong_Kong (GMT+08:00)

This topic contains 6 replies, has 2 voices.

Last updated by Luo Yang 7 years, 1 month ago.

Assisted by: Luo Yang.

Author
Posts
#591005

Hi, I have a view where is inserted another view with Group of Repeating Fields (as a child post). The view with child post has this code inside:

<h2>[wpv-post-title]</h2> <button id="tlacitko-vice" class="btn btn-info" type="button" data-toggle="collapse" data-target="#zobrazit-vice" aria-expanded="true" aria-controls="zobrazit-vice">VÍCE</button>
	  </div>
	  <div id="zobrazit-vice" class="collapse out">
		[wpv-post-body view_template="None"]
      </div>

If I click on the button nothing happens. If I place code for button into view for parent, it works. And after, how to secure that only the related post-body will show, not all of them?

#591114

Dear Dave,

If you put the custom JS codes into the parent view, the custom JS codes will be triggered only once, if you put it into child views, since there will be multiple child view be rendered, the custom JS codes will be triggered multiple times.

For the question:
how to secure that only the related post-body will show, not all of them?

Please elaborate the question with more details, what kind of post-body is the related post-body?
If you need to display the child posts which are assigned with current parent post, please setup a post relationship filter in the child view:
Select posts that are a children of the current post in the loop.
see our document:
https://toolset.com/documentation/user-guides/querying-and-displaying-child-posts/

#591265
toggle-more-info.png

Hi Luo,

each child CPT has [wpv-post-body], but I want to have it available only if you click the button "VÍCE". The problem is that all the buttons (Loop item in View) will collapse only the first post body text (in example "Lorem ipsum..."), not the related text.

#591384

This needs custom Javascript, for example hidden link
if you need assistance for it, please provide a test site with same problem, fill below private detail box with login details, point out the problem page URL and where I can edit your custom JS codes, I need a live website to test and debug, thanks

#591519

Thanks for the details, I have done below modification in your website:
Edit the view
hidden link

in section "Loop item in Zobrazení variant zážitků", change the codes from:

  <button data-toggle="collapse" data-target="#obsah">VÍCE</button>
  <div id="obsah" class="collapse">

To:

  <button data-toggle="collapse" data-target="#obsah-[wpv-post-id]">VÍCE</button>
  <div id="obsah-[wpv-post-id]" class="collapse">

You will need to assign a unique HTML ID attribute for each div tag, please test it again.

#591544

Thank you, it nicely solved the problem.

#591856

You are welcome.