Hello,
I am planning to implement the following table:
Y (vertical) axis: all wp users, members a custom role
X (horizontal) axis: all posts of a custom post type
Coordinates are checks (ticks), if a certain user has created a child post of the corresponding post on the X axis, or not.
So, we should see which users have created child posts of which parents, and which users have not.
Is that possible with Views? If so, please send some guidelines, on how I could build the table structure. I am okay with the actual code, I just do not know how I can setup a view to implement it.
Thanks in advance,
Kostas
Dear Kostas,
Thanks for the details, I think it is possible within a three levels view, for example:
1) Grandparent view list all posts, display below parent view, and pass post ID as the attribute of shortcode [wpv-view],
for example: [wpv-view name="parent-view" mypostid="[wpv-post-id]"]
one post one table row.
https://toolset.com/documentation/user-guides/passing-arguments-to-views/
section "Controlling the filter with shortcode attributes"
2) Parent view list all users, display below child view, and pass one parameter as attribute of shortcode [wpv-view], for example:
[wpv-view name="child-view" mypostid="[wpv-attribute name="mypostid"]"]
Each user display as one table grid.
3) Child view list child posts, filter by two filters:
a) Post author filter
Select posts with the author set by the parent User View.
https://toolset.com/documentation/user-guides/filtering-views-query-by-author/?
b)Post relationship filter
Select posts that are children of the Post with ID set by the shortcode attribute mypostid.
eg. [wpv-view name="view-name" mypostid="123"]
wp-types.com/documentation/user-guides/querying-and-displaying-child-posts/
Hi Luo,
Thanks for your response. I am afraid I find it hard to follow you.
Can you please elaborate a bit?
Thank you,
Kostas
I have already provide detail steps in above answer:
https://toolset.com/forums/topic/table-of-users-and-cpts/#post-590111
I am not sure which step you need to be elaborated.
If you still need assistance for it, please provide a test site with same problem, I can setup a demo for you.
Hi Luo,
Please enable private posting.
Thanks,
Kostas
The private message box has been enabled, please provide the credentials, also point out the problem page URLs. thanks
Here is the example in your test site:
1) three views:
a)Grandparent view list all posts
versteckter Link
b) Parent view list all users
versteckter Link
c) Child view list child posts
versteckter Link
Put the grandparent view into a page:
versteckter Link
It is only an example, you will need to customize the HTML structure into a HTML table
Hi Luo,
Thanks a lot for providing the example.
However it does not seem to suit my needs. I am trying to build something like the attached image.
For example, if user1 has created a child (answer) of 1A (sample), then a check is printed, etc.
In your example, users are printed multiple times, which I do not need.
Do you think it's possible to build a table like the attached image, with Toolset??
Thanks again,
Kostas
For the question:
Do you think it's possible to build a table like the attached image, with Toolset??
Yes, it is possible to build such a table like the attached image, As I mentioned above, you will need to customize the HTML codes structure into a HTML table, here is a document about HTML table:
versteckter Link
Please let me know if you still need assistance to setup the HTML codes.
Yes, any help to setup the HTML codes will be appreciated.
Thanks!
As your request, I am trying to setup table HTML codes for you, but your test site is very slow in my side, so I am export the database dump file from your website to my localhost, will feedback if there is anything found
I just setup a demo in your website, see the result page:
versteckter Link
Here are details steps:
1) Add below PHP codes into your theme/functions.php:
add_shortcode('hide-it', 'hide_it_func');
function hide_it_func(){
return;
}
Views shortcode [wpv-layout-start] ... [wpv-layout-end] will output an extra HTML div tag, we use shortcode [hide-it] to hide the HTML div tag. We will need to apply it to all below views.
2) Grand parent view, list all Taster users:
versteckter Link
display the parent view with below shortcode:
[wpv-view name="parent-view-samples-posts" author="[wpv-user field="ID"]" cached="off"]
3) Parent view, list all "samples" posts
versteckter Link
display the child view with below shortcode:
[wpv-view name="child-view-answer-posts" cached="off" author="[wpv-attribute name="author"]" sampleid="[wpv-post-id]" cached="off"]
4) Child view, list answer posts, filter by:
a) Select posts that are children of the Post with ID set by the shortcode attribute sampleid.
eg. [wpv-view name="view-name" sampleid="123"]
b) Select posts which author's id is set by the View shortcode attribute "author" eg. [wpv-view name="view-name" author="1"]
And display the result as below:
[wpv-items-found]
<!-- wpv-loop-start --> <strong>Yes([wpv-found-count])</strong>
<wpv-loop></wpv-loop>
<!-- wpv-loop-end -->
[/wpv-items-found]
[wpv-no-items-found]<strong>[wpml-string context="wpv-views"]No[/wpml-string]</strong>[/wpv-no-items-found]
5) Create a view, to list all all "samples" posts, use it as the table header:
versteckter Link
Please check if it is what you want. thanks
Excellent Luo, exactly what I need, thanks a lot!
I have made some changes to show only active samples:
versteckter Link
One last question: At "Grandparent view - Taster users" view, how can I order by user's Last Name?
Thanks again,
Kostas
As you can see, there isn't such a built-in feature within user view, if you agree, we can take it as a feature request, our developers will evaluate it. Thanks
Yes, please take it as a feature request, thank you.
Luo, your help is very much appreciated!
You can now close this ticket.
Best regards,
Kostas