Skip Navigation

[Resolved] Display a parent/childs content in a tree-shape

This support ticket is created 2 years, 4 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 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 33 replies, has 2 voices.

Last updated by Franco Calcagni 2 years, 3 months ago.

Assisted by: Shane.

Author
Posts
#2424537

We need to display in the sidebar a list of parent/child elements in a tree-like shape, We already created the parent-child post types but we don't know how to show the parent only once with all childs under each parent, for example

STUDIO 01
- Architect 01
- Architect 02
- Architect 03

STUDIO 02
- Architect 02
- Architect 03

Where STUDIO is the parent element and ARCHITECTS are the child (please note that an architect can belong to more than one studio).

We just need to display these elements but as you see in the following link we now have the STUDIO that repeats for every ARCHITECT
hidden link

Thanks for any help.

Franco

#2424755

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Franco,

Thank you for getting in touch.

This setup will require the classic view editor in order to achieve. If the classic view hasn't been enabled you can enable it by going to Toolset -> Settings and scrolling to Editing Experience. From there I recommend that you select " Show both the legacy and Blocks interface and let me choose which to use for each item I build".

This will allow you to have access to the classic editor as well as the block editor. From there refresh the page and go to Toolset -> Views.

Now what you will need to do first is to create your Child view that will list your child post and on that child view under the Query Filter section you will add the filter for the Post Relationship. Then select the option "The current post in the loop".

From there you just need to populate your view with the items you want to display in the child view.

Next you need to create your parent view and then add your child view to that parent view. Now the link below will provide an example of how nesting of your views works.
https://toolset.com/documentation/legacy-features/views-plugin/using-a-child-view-in-a-taxonomy-view-layout/#adding-a-view-to-a-view

Please let me know if this helps.
Thanks,
Shane

#2424759

Hi Shane thanks,
in order to achieve this we created a custom template with the new black editor but we get some errors (I opened another ticket for that), is it possible for you to have a look at that ticket?

Thanks,

Franco

#2424791

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Franco,

I've already responded to that particular ticket.

However for this one, my instructions above should allow you to create the tree listing of your Parent and Child posts.

Thanks,
Shane

#2427705
Post relationship.png

Hi Shane,
regarding this topic, we already created from a previous version of Toolset a connection between post types.
I explain you in detail:
We have a post type called SCHEDE which is the description of a particular building.
WIthin that post we need to show in the sidebar all the STUDIOS that built that building and within each STUDIO the <ARCHITECTS that worked for that building.
The result shall be like in the following URL
hidden link
except for the concept that the same STUDIO logo and label shall be displayed once as a parent element and the ARCHITECTS for each studio shall be displayed indented under the STUDIO logo (see the enclosed screenshot).
We know that through the post relationships it is possible to achieve this but we don't know how to do that.
We are creating a custom template with block editor and in the sidebar now we need to insert the blocks needed to display that content.

Please let us know how to achieve the above result

Thanks

Franco

#2427835

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Franco,

The way to achieve this can be found in the post below.
https://toolset.com/documentation/legacy-features/views-plugin/using-a-child-view-in-a-taxonomy-view-layout/#adding-a-view-to-a-view

I've also explained how you can manipulate the parent/child view in my thread here to achieve your goal. If you're having any issues with the setup please let me know and i'll be more than happy to assist.
https://toolset.com/forums/topic/display-a-parent-childs-content-in-a-tree-shape/#post-2424755

Thanks,
Shane

#2427843

Hi Shane,
I tried to follow the tutorial in the posts you indicated but unsuccessfully.
Maybe there is something wrong in the way we created relationship between data.
We just updated the old relationships to the new method by activating the automatic migration by Toolset.

How can we go ahead?
Do you need to have a look at our environment to see if all data and post relationship are correct and try to create a working view?

Please let me know.

Thanks,
Franco

#2427883

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Franco,

Would you mind allowing me to have admin access to the website so that I can have a more detailed look at this for you ?

Please where applicable please provide me with a link to an example page where I can see the issue.

I've enabled the private fields for your next response.

Thanks,
Shane

#2427951

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Franco,

NOt sure I understand the relationship structure.

Have a look at the page you've sent me .
hidden link

I've added the parent view with the child view nest inside it but its returning no results found.

Here is the child view with the appropriate filters.
hidden link

Also here is the view with the Parent.
hidden link

Perhaps i've not selected the correct relationships.

Please let me know if this helps.

Thanks,
Shane

#2427971

Hi Shane,
it's the wrong view, in the URL you sent me we see the whole set of SCHEDE but no STUDIOS and ARCHITECTS.

What we need to achieve is a list of STUDIOS (defined in the post type STUDI) with a subset for each STUDIO where only the ARCHITECTS (defined in the post type ARCHITETTI) are only the data that belong for the specific post type SCHEDA.

If you see the screenshots I sent you and the URL of the OLD site you see what I mean.
Maybe some new relationships between ARCHITECS, STUDIOS and SCHEDE shall be built.
The concept as I wrote in my former message is:

SCHEDA
- STUDIO 01
-- ARCHITECT A
-- ARCHITECT B
-- ARCHITECT C
- STUDIO 2 (if the SCHEDA has a relationship with more than one STUDIO)
-- ARCHITECT D
-- ARCHITECT B (an ARCHITECT can belong to more than one STUDIO)
-- ARCHITECT F
- ARCHITECT G (when an ARCHITECT does not belong to any STUDIO)

The data in the sidebar shall only belong to that specific SCHEDA

I hope this helps.

Please let me know, thanks.

Franco

#2427973

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Franco,

This page below is of the "Schede" post type.
hidden link

In the sidebar you want to display the "Studi" Post Type and its children.

Can you send me a post where all the relationships have been filled out because the post above doesn't have a child Studi attached to it.

Having a post with all the relationships filled out should allow me to setup the relationship correctly.

Thanks,
Shane

#2427983
studio.jpg

Hi Shane,
I sent you this post because it has an example of a STUDIO with 2 ARCHITECTS, you can scroll down the page until you reach the box I sent here in my screenshot attached.
You see that there are 2 Architects Filippo Pagliani and Michele Rossi both belonging to the studio Piuarch, so what I expect to see in the sidebar of this post is something like this:

- PIUARCH
----- Filippo Pagliani
----- Michele Rossi

#2427995

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Franco,

The correct information should be displaying now. The screenshot helped me to identify the correct relationship between the post types.

You should now be seeing the correct Architects. You should now be able to go in and modify the design output of your views as I've setup a very basic example for you.
Here is the child view with the appropriate filters.
hidden link

Also here is the view with the Parent.
hidden link
Thanks,
Shane

#2428009

Hi Shane
unfortunately the page do not display the structure of content I listed in my previous message that shal be:

- PIUARCH
----- Filippo Pagliani
----- Michele Rossi

In your version I see instead the following result:

scheda-studio-arch 119438
Michele Rossi
scheda-studio-arch 119430
Filippo Pagliani

Please let me know if you can achieve the result I listed above or if it is necessary to rebuild the relationships

Thanks

Franco

#2428019

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Franco,

The format is now similar to how you would like it,

However the text "PIUARCH" is this some header title ? Meaning is it dynamically generated from one of the child posts?

Thanks,
Shane