Home › Toolset Professional Support › [Resolved] Post-relationship – Testing and Feedback (and error message)
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 |
---|---|---|---|---|---|---|
- | - | 14:00 – 20:00 | 14:00 – 20:00 | 14:00 – 20:00 | 14:00 – 20:00 | 14:00 – 20:00 |
- | - | - | - | - | - | - |
Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)
Related documentation:
This topic contains 7 replies, has 3 voices.
Last updated by davidM-17 7 years, 1 month ago.
Assisted by: Beda.
As per the blog post, I wrote up information about a site where this might be used, tested it, and included my thoughts. Hope it is helpful.
Feedback - Beta of Types 2.3 with Post Relationship
David McCan
September 29, 2017
Background
My wife is a librarian who reads tons of books. This site was done as a family project that we could work on together. The live site is hidden link. It is using Types, Views, Astra Theme, Beaver Builder and various Beaver Builder add-ons.
The site has evolved over time. It started out with just book reviews. For example:
hidden link
Over time I see a pattern where we create a thematic post and have related book reviews: For example, we have:
• Reading for the Hugo Award
• Coming of Age Stories
• Audiobook tour of US History
These thematic posts might have from 3 to 50 related book reviews.
With the Audiobook tour of US History, there were additional requirements. We needed to have information about the State, the historical period, and the audiobook. Because of the additional info a full page layout was needed.
Current structure
• For the Book CPT I created a book field group, with two taxonomies and tags.
• For the Audio book tour of the US I created a field group for each additional information group:
o Information about the audio book (shows in Book edit screen when Format audio chosen)
o Information about the State (shows in Book edit screen when Tag “Audio book Tour” entered)
o Historical information (shows in Book edit screen when Tag “Audio book Tour” entered)
Challenges
1. Associating books with the Thematic Post. This has been accomplished three ways:
a. By manually adding the books at the bottom of the thematic post. For example:
hidden link
b. By adding a tag to the reviews for that theme and creating a menu item for them. For example:
hidden link
c. By using a map with icons that you click on to go to the review. For example:
hidden link
2. Having and showing fields that only apply to certain types of books. For example, I only want the audiobook related fields if the review is an audiobook, or the state related fields if the review includes the state information. I did not want the database filled with empty fields and I did not want the book editor screen to show fields that were not being used. This was solved by:
a. Conditionally showing field groups if the format was audio or the tag was “Audiobook Tour”.
b. Creating and using different Content Templates depending on the fields included in the review and manually choosing a layout without a sidebar and the content template for the Audiobook Tour reviews.
How the New Post Relationships Might be Used
• For the thematic posts, I could create a one-to-many optional relationship between Posts and Books. Then I would like to be able when creating the Content Template to pull in the related reviews and show them in a table/grid at the bottom of the thematic post.
• My wife intended to only review one book from each state in the Audiobook Tour, but for a couple of states, she has more than one book she wants to include. I could pull the State fields group out and put it into its own CPT and then optionally have a one-to-many relationship between States and Books to avoid entering duplicate information when more than one book takes place in the same state. Having this relationship might also make it easier to output book reviews by state.
How the New Theme Integrations Might Help
• For the regular book reviews there is a sidebar, but for the Audiobook Tour reviews the layout needs to be full width due to the extra information. I’m thinking that the new theme integration might let me set the full-width layout for the Content Template, which will be nice.
Testing on New Site
1. To test out the relationships, I imported the Book CPT and data from the live site into a new test site. I created a new CPT called States and added the State field group to it.
I created two Relationships: one-to-many States to Books, and one-to-many Posts to Books. I created a State called Maryland and a book called Life in Maryland and filled in the fields, then connected them. I connected that book to the Audiobook thematic post. The state information looked fine on the Book post, but the book fields on the bottom of the state edit screen look jammed together (there were a lot of fields).
It would be a nice option to only see the association in a list without all of the editable fields, as sometimes that would be sufficient. I would like to be able to create the Content Template as if the fields were in the same CPT. If there were multiple entries in a one-to-many relationship, I would like to have those be treated as if they were repeating fields that would be output in a loop.
2. I went to the Posts list with the thought that I would like to associate the Books mentioned in the Coming of Age thematic post with that post, but got this error:
“Recoverable fatal error: Object of class stdClass could not be converted to string in E:\laragon\www\typestest\wp-content\plugins\types\vendor\toolset\types\embedded\includes\conditional-display.php on line 88”
I was unable to access any posts, except for Hello World.
David
Thank you for the feedback here!
Let me reply to some of the details.
Having and showing fields that only apply to certain types of books. For example, I only want the audiobook related fields if the review is an audiobook, or the state related fields if the review includes the state information. I did not want the database filled with empty fields and I did not want the book editor screen to show fields that were not being used.
That's not necessary.
By default Types Fields will store nothing in the Database. Only if you select "save 0 if empty" then something will be saved.
Hence, there will be no empty Fields.
I went to the Posts list with the thought that I would like to associate the Books mentioned in the Coming of Age thematic post with that post, but got this error:
I was not able to replicate this, but I am quite sure I follow the wrong steps.
I will investigate this further.
Could I ask for a site's snapshot of this test site?
Then I can directly start to debug the issues.
As for the feedback received here, I will forward this to our Developers, and they will eventually contact you here if they need more information or have things to share.
Thank you!
David,
Are you sure that a book should appear only on one post? To me, it looks more like adhering to a technical limitation, rather than how things should actually be.
If you write a book review, doesn't it make sense to be able to show it on a number of posts?
For example, you could show it on the post for which that review was originally written. Then, you could have another roundup post about this year's most popular reviews and you would show some of the reviews there again.
To further simplify things, you could separate the audiobook CPT from the paper books CPT. This way, you only display the relevant fields on each of them (for editing and when displaying) and you don't need to use so much conditional logic.
I don't know what you do, so maybe these suggestions aren't relevant.
Hi Amir,
Thank you for taking the time to comment and suggest.
You are absolutely correct. There is no reason that books should only show on one post. I was only looking at the existing use, but what you say makes sense.
I'm not sure if separating books from audiobooks would help in our case. The audiobooks have the same fields as books and add a few more, so they are extending the book CPT. Also, I imagined that having them as the same CPT would help with searching.
--- Additional Suggestions / Oddities from further usage:
-- I had suggested the option to only show the summary relationship without all of the fields. I was thinking about that and maybe it would be better to just show the title, with an arrow next to it to expand it.
-- Relationship fields are only allowed for many-to-many relations. In my test, I separated States from Books. When on the State edit screen I clicked to enter a new book and got a popup with the fields to fill in. On the right side of that popup, there is a header that says "Relationship Fields", even though there are none.
-- For a CPT you can identify some fields to show as columns on the post type listing. I'm not sure if it is practical, but it would be useful when looking at the list of all Books or all States, to see what they are related to. There is no place to see all books that took place in California, for instance.
-- As per your suggestion, I changed the relationship of Posts to Books to be many-to-many. I did not see the option when doing so: "Intermediary Post Type visible in WordPress admin menu". That option does show when you first create the relationship.
---
The introduction of Relationships seems almost as big as "Views" itself. It obviously required a lot of planning and engineering. Congratulations.
Best regards,
David
I am sorry, I missed the private section where you already provide all the data.
I am investigating it, thank you!
Related to your first post:
https://toolset.com/forums/topic/post-relationship-testing-and-feedback-and-error-message/#post-574999
Most of the display approaches should be possible with Views when it's ready for the M2M relationships.
The problem on the child posts fields, I attached 2 screenshots of what I see in your duplicator.
To me, one table is correctly sized, the other is escaping the boundaries of the table borders.
Is that what you mean?
The fatal error is replicable on your install, not yet locally with the same settings, but I am investigating this further to avoid hidden issues.
Related to your reply:
https://toolset.com/forums/topic/post-relationship-testing-and-feedback-and-error-message/#post-575175
I also will make sure we discuss a way to show/not show the fields in a Child Post edit table (just as it is currently in the stable version when you edit the Parent Post type you can select Fields to display in the Child Post table).
The relationship fields section is displayed even if there are none, we also filed this.
The request to show relational information on the Posts Admin List is known to us.
It has been required in past, and it is filed as a feature request.
I think the main concern here is Performance. Since now some data is stored in new tables we can maybe do it now.
We will discuss this.
"Intermediary Post Type visible in WordPress admin menu" is present on the first setup of an M2M Post type, it is right under Create an intermediary post type.
If this last one is not checked, the option " Intermediary Post Type visible in WordPress admin menu" is hidden too.
Thanks for the valuable feedback David!
Hi Beda,
"The problem on the child posts fields, I attached 2 screenshots of what I see in your duplicator.
To me, one table is correctly sized, the other is escaping the boundaries of the table borders.
Is that what you mean?"
No, it did not do that on my install. It stayed within the box. My comment was that there were so many fields that it looked very tight and jumbled. My suggestion is that there be a caret next to the title and the details hidden. When clicked then the details expand to show.
---
"The fatal error is replicable on your install, not yet locally with the same settings, but I am investigating this further to avoid hidden issues."
As I said, the data was imported before I made the relationship. It is possible there was some corruption in the export/import process. If I recall correctly, I was able to see the data before making the relationship. Another wrinkle is that some, but not all, of the Posts, were laid out using Beaver Builder.
---
"Intermediary Post Type visible in WordPress admin menu"
I'm not sure if my feedback was clear on this one. The issue is that the optional setting to make the intermediary post type visible in the admin does not show when editing the relationship. In my case, it was originally a one-to-many and then changed to a many-to-many. Going back to edit it again and the option doesn't show.
---
Best regards,
David
Hi Beda,
I don't need any further response as I think you have everything now. Thank you for the follow-up. If you need anything further then feel free to email me.
Best,
David