Skip Navigation

[Resolved] A View with other Childpages from the same Parentpage

This support ticket is created 3 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 – 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 8 replies, has 2 voices.

Last updated by TorstenR3514 3 years, 3 months ago.

Assisted by: Waqar.

Author
Posts
#2151611
Bildschirmfoto 2021-08-25 um 17.10.46.png
Bildschirmfoto 2021-08-25 um 17.09.59.png

Tell us what you are trying to do?
I am using views of child pages that are beeing displayed on the parent page if the checkbox "show-child-pages" is activated. That works fine with the Query Filter "Select posts whose parent is the page where the View is shown."
Now I am trying to create a View on the Childpage with other Childpages who have the same Parentpage, if show-child-pages is activated at the Parent page

I am using the blockeditor

My problem:
Can't find the conditional “Field show-child-pages from Parent Page is equal to 1.”
Can't find a query filter for the View which selects Childpages of the same Parent page

What is the link to your site?
Main Parent: hidden link
Child of Parent: hidden link
Child of Child: hidden link

#2152491

Hi,

Thank you for contacting us and I'd be happy to assist.

1. Assuming that the slug of the checkbox field is "show-child-pages" you can use the item attribute, to get the value from the parent page, like this:
( ref: https://toolset.com/documentation/programmer-reference/views/views-shortcodes/item-attribute/ )


[types field='show-child-pages' output='raw' item='$parent'][/types]

The same shortcode can be used in the conditional block's advanced editor, to see if the value is equal to '1':
( example screenshot: hidden link )


( ( ' [types field="show-child-pages" output="raw" item="$parent"][/types]' eq '1' ) ) 

As a result, the blocks inside this conditional block will only show if the parent page is set to show the child pages.

2. You can create a single classic/legacy editor view to cover both cases:

case a). To show the current page's child pages
case b). To show all the child pages which share the same parent page as the current child.

You'll create a classic/legacy view that shows the pages, and set the post parent query filter with the option "Post with ID set by the shortcode attribute: wpvchildof".

For case a, you'll pass on the current page's ID in the view's shortcode, like this:


[wpv-view name="view-name" wpvchildof="[wpv-post-id]"]

And for case b, you'll be able to pass on the current page's parent ID in the view's shortcode, like this:


[wpv-view name="view-name" wpvchildof="[wpv-post-id item="$parent"]"]

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

regards,
Waqar

#2152495

Hi Waqar,

thank you for the fast feedback (allways a pleasure to work with toolset support).
Will take some days to check this, as I am busy with an other project, but I'll try as soon as possible 😉

Thx Torsten

#2152601

You're welcome Torsten and I'll wait to hear back from you.

#2153159
Bildschirmfoto 2021-08-27 um 01.36.00.png

Hi Waqar, so for first I managed to follow your instruction. Thx a lot. See related link. "View other Childs from same Parent by Legacy Editor"

The problem is that the grid wich comes with the block editor is so much more convenient than the table-based grid from the legacy editor. So that I tried to work with the block editor instead. "View other Childs from same Parent by Block Editor"

I created an new view block and applied it to the post parent query filter. Then I placed it twice using a shortcode. After refreshing the content template, I deleted the view, which usually works because the view itself is not deleted. The only problem is that the grid is lost when you place a view block via shortcode 🙂

So it looks like I'll have to handwrite the css if I want to have a real grid, doesn't it?

#2153203
Bildschirmfoto 2021-08-27 um 02.19.22.png

Hi Waqar

I tried differently and reassigned the deleted view in a view block as existing view. I was able to apply the [wpv-post-id item="$parent"] to the Parent setting at the view block (see screenshot). It looks like he don't applies the querry filter in the backend, but in the front end he does. The only thing missing were my custom classes. For this I added a surrounding container and applied them there.

see link: last exsample

What do you think, is this a legal solution? Or is there a better way to use the grid from the view block?

#2153683

Thanks for the update and glad that you're were able to make this work.

Your workaround seems to be safe to use, if you prefer to use the design flexibility offered by the blocks-based view.

For cases, where you have to insert the blocks-based view using shortcode or as an existing view, you can create a separate new draft page and create your blocks-based view there. This way, you'll have the original page available where the view was originally created, in an event you have to make some changes to it later. On the actual pages, you can insert that view as an existing view using the view block or the view's shortcode.

#2154177

Hi Waqar,

I updated the example page and I think this will be very useful in the future and I will be using it quite a lot! Thank you for your help.

By the way, I can simply place the view a second time as an existing view and edit it as the original if I want to make changes. I checked the scan under Tollset / Views and it is marked as "used", even if the "original" was deleted. This prevents me from accidentally deleting it

My issue is resolved now. Thank you!

#2155335

Hi Waqar,

You will probably not get noticed by this answer, but I just have to say thank you again!

I've just implemented this feature in a customer project and it takes content quality to a whole new level.

I shall definitely make use of this possibility more often.

Greetings Torsten