Skip Navigation

[Resolved] my first view and layout with relations

This thread is resolved. Here is a description of the problem and solution.

Problem: I have a site that displays Tournaments (of Matches), Matches (between Fighters), and Fighters. How can I create a display that shows the results of a single Match, between two Fighters, along with the Match results and statistics of previous Matches between these Fighters?

Solution: Begin by creating posts for Fighters and Matches. Add custom fields and taxonomies for organization. Create a View that shows a single Fighter, based on a shortcode parameter. Add the relevant fields here to display Fighter information. Create a View that shows a Match. Include your single Fighter View twice - once for each Fighter. Use custom fields in your Match post type to define the Fighters in each Match.

This support ticket is created 7 years, 6 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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

Author
Posts
#508267
508151-match_1_1.jpg

Hi,
i finished adding all custom fields, relations, taxonomies structure.

can you please help me with the first view and layout on my structure ? i'm only interested in output data as i want, not the design ?

when i click on a match i want to show me the two fighters with last 5 matches between them from previous matches (first row of vertical lines) and last all 5 matches of each fighter (second row of vertical lines) and bars should be links to those matches. On the next table (below) i want to see all previous matches with result from current tournament.

i can also set you an admin account if there's a need.
thank you in advance.

#508645

Hi, I'll be glad to help if you can provide me with a bit more information.
- How are your posts organized? How are tournaments and matches organized?
- What kinds of post relationships are used?
- What taxonomies are used?

#508993
kw-cpt.jpg

Hi Christian,
thank you and sorry for the delay

i attach an image with all details
Dan

#509110

Yes, I think that admin access makes sense at this point because we need to discuss technical details about each post type, and the relationships between those posts. Please provide the login credentials for me here in the private reply fields I have enabled. Thanks!

#509901

Hi, I'll try to help get you going.

- Change your Matches custom field for Home and Away Fighters to save their post ID, not their post Name. You can still show the name in the select option, but you should save the ID. You'll need to be able to query on these values later, and it's better to compare IDs than strings.
- Modify your Single Fighter View to accept a shortcode parameter 'fighterid'. This will allow you to use the same View to display Home and Away fighters. This is why it's important to change your custom fields to save IDs. Include the match_away-fighter custom field value. In your Layout Visual Editor, you should use the shortcode parameter like this:

[wpv-view name="single-fighter-view" fighterid="[types field='match_away-fighter'][/types]"]

- Inside this View, you can add your Post Title to display the fighter's name, the image custom field to display the fighter's image, and so forth
- Once you have the fighter name and image showing up correctly, edit your Layout again. Copy the single-fighter-view, and use the match_home-fighter fighterid to display the same information about the home fighter.

Let's get this set up before moving on to the match result indicators. Let me know how it goes, and we'll take it from there.

#510291

Hi,
first of all thank you again.

- i have changed Matches to save fighter ID (i knew this is the proper way to do it but i was testing with post title because i didn't know to output the result)
- i added filter to View for Single Fighter (ex Single Fighter View)
- i added in both Filter Editor's View and Layout's Visual Editor

[wpv-view name="view-for-single-fighter" fighterid="[types field='match_away-fighter'][/types]"]
[types field='fighter_first-name'][/types]

with no success 🙁

#510411

Hey I made some changes for you to help display some information. Here are the places I noticed a problem:

1. In your Layout, I changed your fighterid shortcode parameter to look like this:

fighterid="[types field='match_away-fighter'][/types]"

Yours had some extra information in there that was not necessary.

2. In the Single Fighter View, you added your content to the Filter Controls, instead of the Loop Output Editor. I moved this content for you:

[wpv-post-title]
[types field='fighter_first-name'][/types]
[types field='match_away-fighter'][/types]

Take a look at how this works. The content for each fighter will be displayed by the Loop Output editor. You shouldn't need to add anything to the Filter Controls for now. Why don't I let you take it from here and see if you're able to get more information about each Fighter to show up. Let me know when you get stuck again.

#511082

Everything is working well but there are few more questions 🙂

i created another view to take the country flag and although i specified image width and height it is ignored in layout, so i added a class named flag and set the size. why ignores size from view ?

in layout if i add a simple text followed by a shortcode, they doesn't stay on the same line.

when i add a match i used radio to select who wins and i don't know why in the options i set it also appears uncategorized posts 😀 (post fields "Match: Finished")

post title has the option [wpv-post-link], how can i add the link to any other fields ?

Thanks

#511227

Hi - I'll try to answer these questions for you. In the future, you'll get the fastest support by creating separate tickets for each concern, but for now I think I can help here.

why ignores size from view ?
I'm not sure, I would need to see this to determine why. Can you give me a URL where I can see it? I see the flag images at /match/cristian-spetcu-vs-mansour-yaqubi/, and the CSS sets the width of each image at 45px. That seems to be working.

in layout if i add a simple text followed by a shortcode, they doesn't stay on the same line.
This could be because your shortcode generates a block-level element, like a <p> or <div>. You may be able to use CSS to make your text and the shortcode render as inline elements, which would help keep them on a single line. If you can show me in the site where this is happening, I can give you some CSS help.

when i add a match i used radio to select who wins and i don't know why in the options i set it also appears uncategorized posts ? (post fields "Match: Finished")
I'm not sure I understand. Are you talking about the wp-admin area? You can modify your custom fields to show only on certain post types. Go to Toolset > Post Fields, and edit your group. Look for the section "Where to include this Field Group", and click "Edit". Make sure only the Match post type is selected.

post title has the option [wpv-post-link], how can i add the link to any other fields ?
If I understand you correctly, you would like to add a link to a post, but instead of using the Post Title for the link text, you would like to use another custom field. Is that correct?

If so, you can use the format [wpv-custom-field name='wpcf-custom-field-slug']. Here's the documentation for this shortcode:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-post-field

#511232
Screen Shot 2017-04-09 at 17.09.11.png
Screen Shot 2017-04-09 at 17.07.35.png
Screen Shot 2017-04-09 at 17.07.03.png

why ignores size from view ?

<wpv-loop>
      [types class='flag' field='country_flag' alt='%%ALT%%' title='%%TITLE%%' width='15' height='15' align='none' resize='proportional'][/types]
</wpv-loop>

i aded class='flag' and style it, that's why is working but i was asking what is the use of width='15' height='15' if it does not work like this when i render the view inside the layout visual editor?

in layout if i add a simple text followed by a short code, they doesn't stay on the same line.
indeed the short code generates a block, i thought there was a setting or something to stay inline. No need for CSS help. we stay at Toolset Q&A 😛

when i add a match i used radio to select who wins and i don't know why in the options i set it also appears uncategorized posts ? (post fields "Match: Finished")
yes, in the admin area and i know what you say but i'm tell that uncategorized posts appear as a radio option. I'll upload a picture. Actually it seems al kind of post appears in that checkbox list items. I just checked.

post title has the option [wpv-post-link], how can i add the link to any other fields ?
thanks

#511246

i aded class='flag' and style it, that's why is working but i was asking what is the use of width='15' height='15' if it does not work like this when i render the view inside the layout visual editor?
Types does not add width and height attributes to your image tags. Instead, it actually creates resized images for you. The problem here is that Types can only resize images in the Media Library, not images that are part of your theme files. In /wp-admin/post.php?post=504&action=edit, you can see that the Romanian flag image is included in your theme files, not the Media Library. If you would like to be able to resize these images in Views, you must include them in your Media Library.

Actually it seems al kind of post appears in that checkbox list items. I just checked.
This is unusual. Can you temporarily disable all non-Toolset plugins and activate the parent Toolset Starter Theme? Does this resolve the problem?

#511251

Thanks
i changed the theme and it works. I checked deeper and it was one of my function 🙁

#511255

Okay I understand. If I've answered your questions, may I kindly ask you to mark this ticket as "resolved" so we can close it out? You may open new tickets any time when you have a concern.

Thanks! 🙂

#511256

OK, thank you again.
See ya later 🙂

This ticket is now closed. If you're a Toolset client and need related help, please open a new support ticket.