Skip Navigation

[Resolved] Nested Views with relationships

This support ticket is created 4 years, 9 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
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 15 replies, has 3 voices.

Last updated by martinP-13 4 years, 8 months ago.

Assisted by: Nigel.

Author
Posts
#1552205

brilliant thanks nigel ,i got a whole bunch of the site done with this info, im 99.999999% there now thankfully , i have 2 little issues
on this page here hidden link with "VIEW THE RESULTS OF DOGS OWNED BY TEST PERSON C." expanded i cannot get just the place for the dog to be visible , and the breeder of the dog shows persons that didnt breed the dog.not for the lack of trying....

single peron view is hidden link it calls in

hidden link which calls

hidden link which then calls

hidden link for the place and

hidden link for the breeder

I would really appreciate a pointer , i will even invite you to my party to celerbrate the end of my long long toolset journey.....

thank you so much
martin

#1552261

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

The View id=20373 queries dog-appearances and outputs the place custom field from those posts.

It's outputting all dog-appearances.

That means the Query Filter you are using to limit which dog-appearance posts should be returned by the View are not working.

And it looks like you are passing values for the Query Filter using shortcode arguments, as we discussed in the last ticket.

Maybe the values that are being passed are wrong, or at least not what you are expecting.

What I suggest is that where you insert a nested View that you are passing attributes to, for debugging purposes you print the values being passed before where you insert the View.

So if you insert that View with...

[wpv-view name="view-36" wpvrelatedto="[wpv-post-id item='@event-person-appearance.parent']" wpvrelatedtodog="[wpv-attribute name='wpvrelatedto']"]

try outputting the shortcodes used to provide the attribute values first, e.g.

<p>wpvrelatedto: [wpv-post-id item='@event-person-appearance.parent']</p>
<p>wpvrelatedtodog: [wpv-attribute name='wpvrelatedto']</p>

[wpv-view name="view-36" wpvrelatedto="[wpv-post-id item='@event-person-appearance.parent']" wpvrelatedtodog="[wpv-attribute name='wpvrelatedto']"]

Also, as a general rule while you are tracking down these problems, in the output of each View be sure to output the posts being returned by the query (and not just, as is often the case, the title of a related post), e.g.

<p>current post: [wpv-post-title] ([wpv-post-id])</p>

Together, these will indicate where things are going wrong (and hopefully point you towards understanding why).

#1552913

after almost 12 hrs of trying Nigel I have given up , i think this last bit is literally IMPOSSIBLE , i started the whole process of the view again and again and again , it always ended the same way , it is literally impossible to show this info . im stumped

#1553585

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Nigel is having a holiday today. He will get in touch with you as soon as he back to work tomorrow.

#1554835

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Martin

What happened when you tried outputting the values of the attributes you were passing to the Views? (https://toolset.com/forums/topic/nested-views-with-relationships/#post-1552261)

That should have left a trail of evidence for you to follow where you could compare the IDs that you were expecting to be passed with what was actually being passed.

It's manual effort, but for such a complex site I don't see an alternative.

#1554841

i couldnt get the correct id to show , it was always the wrong post type etc , i used the info you kindly provided for me from the main view all the way down to the info i wanted to display, i dont think its possible.... i must be missing something , its cpt person that is then showing that person appearences role in the event. the event shows the dog associated to the event , i want to show which person is the breeder of that dog(which is a cpt) , it doesnt sound difficult , but i mst be missing something somewhere. its very frustrating as it is literally the last 2 bits to do. thanks nigel
martin

#1554853

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

I'm sorry but I can't dig that deep into a client site.

I can teach you how to use Toolset products.

I can give you tips on how to troubleshoot problems when they arise.

But I can't roll up my sleeves to sift inch-by-inch for clues in a complex arrangement particular to one client site, that's a job for the site developer.

Where I gave an example above of how you might print out the values of the attributes being passed to a View, doing the equivalent for each of your chain of Views will show you the IDs of the posts being passed from one to the next, which should give you exactly the information you need to identify where in the chain it is failing. If you look at your posts and note their IDs you should be able to predict what each attribute value should be, then compare it with the actual values, and that will reveal the problem.

Once you reach that stage and can tell me where it is failing I may be able to offer an opinion as to why you are not seeing what you expect.

I'm sorry to put the ball back in your court.

#1554879

ok nigel , ill see what else i can do .i do know where its failing by using the info you gave , i will go again tonight and if no good i will documnet exactly whats going on and failure point.
thank nigel

#1555683
nigel1.png

ok , thanks nigel for the guide of how to identify where its breaking down , i wish i had learned that weeks ago! , now to the problem

handlers and owners where using the same views and where split by the "role" of handler and owner. i have made new view now for handler so each have there own views to keep it simpler and allow me comparisons.

i have the post type persons ,person appearance , dog and dog appearance.

To enter my data
1 &2) i add all persons and dogs that featured in any given event using the cpt "dogs" and "persons"

3) I then add a cpt "dog appearance" this lets me assign a place , an event and the dog i previously created.

now here is what is causing my problem i believe

i add 4) here hidden link
4) i now add cpt "person appearance" this lets me add a) "Person Appearance Role*" b) "Person Appearance Dog " c) add the person and d) add the event .

peron appearance dog is added to this screen using a custom code snippet "person-appearance-dog-for-handler-and-owner" located here hidden link .

if my understanding is correct , when the dog is assigned , it is passed as a field and not a post so therefore has no I.D , as there is no I.D i cannot use the relationship person<---->dog .

as i stated above i used the hadler part to debug and keep simple.

hidden link calls view 555 .

view 555 here hidden link

here i have correct person appearance. i have the correct dog as a field and it cannot output an I.d

screenshit attached

#1557281

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Screenshot 2020-03-20 at 12.41.45.png

Sorry for the delay getting back to you, I got pulled for some other urgent tasks yesterday.

as there is no I.D i cannot use the relationship person<---->dog

There is no relationship between persons and dogs.

I'm not sure of the history, but the dog that pertains to a person-appearance is saved as a custom field. The code snippet dynamically generates the select dropdown options to include all dogs. The display value in the select dropdown is the dog post title, and the saved value in the database is the ID of the dog post.

So for any existing person-appearance post the ID of the "related" dog is the value of the "Person Appearance Dog" custom field.

If you output the field using a Types shortcode it will by default output the display value. If you want it to output the saved value then you need to specify that when inserting the types shortcode (screenshot), which means it will add the output='raw' attribute.

#1557415

thanks nigel that cleared that up in my mind. in the view 555 here hidden link
the shortcode allready uses the "raw" , why can i not get the post id of the dog printing in the front end nigel ? once i can get the id of this dog im confident i can finish up these last items.thanks

#1557563

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

It looks like it is working to me.

You have this in the output template:

 [wpv-post-link item="[types field='person-appearance-dog' output='raw'][/types]"] how do i pass the id of this dog?<br>

So you are trying to output a link, and not for the current post (which is a person-appearance post), rather for the post whose ID is set by the person-appearance-dog field, i.e. a dog.

And it is outputting a link to the test dog 3 post.

So that's what's expected, it's working.

Did you want it to do something else?

#1557829

yes, i want to show the breeder of that dog!

#1559997

yes the dog is displaying as it should

it is also showing the event related to the dog where X was the handler correctly
i can then show the persons that where judges at the event,
i can show the owner of the dog at the event.

what i cant seem to do is show the info related to the dog for that event

ie the custom field to show the dogs place at the event "Dog Appearance Position"
the person who bred the dog (I do have a person - dog relationship here hidden link ),
the sire and the dam of the dog.

it seems that no matter what i do i cannot pass the id of the dog to the next view. to grab the above missing pieces , what am i doing wrong or missing>? it isn't for the want of trying i can assure you

these are literally the final issues i have luckily but can't seem to get past it. thanks in advance.
martin

#1560303

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

So this works: [types field='person-appearance-dog' output='raw'][/types]

It outputs the ID of the dog belonging to a person appearance post (as recorded in the person-appearance-dog custom field.

You lose me then about what comes next.

i want to show the breeder of that dog

What is the breeder of the dog? Is that a person post? But it is different to the owner or handler?

what i cant seem to do is show the info related to the dog for that event
You have the ID of the dog available with that shortcode, and you should be able to pass it to a View in much the same way as you have done previously.

You can test if it works. Create a View to display dogs. Add a Query Filter for the post id where the value comes from a shortcode attribute. Just output the post title. Insert that View and use the [types field='person-appearance-dog' output='raw'][/types] shortcode to pass the dog id, then see if it outputs the correct dog post title.

If so then using that shortcode to pass the value from the custom field is working.