Skip Navigation

[Resuelto] Need help with a view

This support ticket is created hace 6 años, 5 meses. 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.

Hoy no hay técnicos de soporte disponibles en el foro Juego de herramientas. Siéntase libre de enviar sus tiques y les daremos trámite tan pronto como estemos disponibles en línea. Gracias por su comprensión.

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)

Etiquetado: ,

Este tema contiene 6 respuestas, tiene 3 mensajes.

Última actualización por ScottM9386 hace 6 años, 5 meses.

Asistido por: Luo Yang.

Autor
Mensajes
#916935

Hello,

I'm using the most recent versions.
I have the following CPT's
Works
Tracks
Writers
Clients
Pitches

The Relationships are:
Works - Tracks (one2many)
Works - writers (many2many) - has intermediary cpt with fields
Pitches - Tracks (many2many) - has intermediary cpt with fields

ALSO - Pitches has a post reference field to Clients.

I would like to do the following view as a table (columns not necessarily in this order)

Track Title | Work Field X | Writer Title | Writer intermediary cpt field X | Pitches field X | Pitches intermediary cpt field X | Pitches post reference to Client Title

I can get some of the columns above but I can't get them all together.

Thank you!!!
regards,
Scott.

#916951

Where exactly shall that be displayed?

We need to tell the View what data to get from where so to display it's related posts.

For example, if I setup your exact schema locally and want to display what you show above on any page, then:

- I set up the Exact Post Types and connections + Fields as you outline
- I create a View that queries the most "Common" Custom Post Type, that is NOT an *explicit single parent*:
Tracks.
- In the View Loop, I can directly display all Tracks with the ShortCode for the Post title:
[wpv-post-title]
-- I can display the direct related posts to the tracks if they are single parents (Works) by simply calling the Parent Title Field:
[wpv-post-title item="@work-track.parent"]
---- I can display the Writer, related to the work which is related to the current Track.
Here you need a second View, which queries the Writer Post Type, and has a Query filter as:

Select posts in Any relationship that are related to the Post with ID set by the shortcode attribute wpvrelatedto.
eg. [wpv-view name="view-name" wpvrelatedto="123"]

This View is now inserted in the First View's Loop and you pass a ShortCode Attribute to pas the ID of the parent Writer:
[wpv-view name="writers" wpvrelatedto="[wpv-post-id item='@work-track.parent']"]
Of course in that same view I can add other Fields as well belonging to writers or their connections.
--- I can display the Pitches related to this track as well with the same method:
[wpv-post-title item="@pitch-track.parent"]
As well I can display their fields the same way, or reference Fields.

The setup is relatively complex.
It may as well generate some performance slow downs if you plan to have a massive amount of posts in those connections, but all over I see no issue implementing this.

The Design will be a problem to keep in one table, as the View, which we insert in the other View's loop, will break any surrounding wrapper HTML, as that will always come packed in View's Standard HTML loop.
So, you can for example not output the contents of View A in View B inline with any other content due to the default HTML DIV that wraps your View Loop

However, from the point of view to create the data structure and its query, that should be possible as above outlined with Toolset View

#917077

Hi Beda,

Thank you. I seem to have it all working, as a table, no problem. I need some info presented as a table so user can export to csv or excel (I'm using DataTables to parse the table. It has this function).

Could there be a potential problem with <td>[wpv-post-title]</td>?
I've read that shortcode in html could create an issue, though so far it hasn't.
As far as performance issues. It's possible I could have a few thousand posts in the table...might this be a problem?
Thank you!
Regards.

#917276

Q1) Could there be a potential problem with <td>[wpv-post-title]</td>?
The shortcode [wpv-post-title] is using wordpress function get_the_title() to retrieve the post title, it should be any potential problem. And you can setup your own custom shortcode to get the post title with the function directly:
https://developer.wordpress.org/reference/functions/get_the_title/

Q2) It's possible I could have a few thousand posts in the table...might this be a problem?
Yes, it is possible, but it depends on your web serve capability.

#917283

Thanks Luo,

You said:
"The shortcode [wpv-post-title] is using wordpress function get_the_title() to retrieve the post title, it should be any potential problem."
I think you meant shouldn't?
Regards

#917297

Yes, you are right, it is a typo, I mean it should not be the problem

#917492

Thank you!