Hi everyone,
I haven’t used ExpressionEngine for quite some time and it’s good to be back to it now that it’s free. I think it’s a great CMS.
I am used to version 2 so I’m now studying version 5. In particular I’m building some exercises to understand better the relationship fields, which look quite powerful. While doing this I banged my head into the wall a little bit while studying the {siblings} tag. The problem I encountered was the use of the channel parameter within this tag.
I’ve built the following channel sets and have populated the Students channel with 9 people. I have also created three Classes (with 3 students each) and 2 soccer teams (with few students playing in each team and a couple of leaders per team).
Classes title url_title students Relationship (Students, Multiple) Teams title url_title players Relationship (Students, Multiple) leaders Relationship (Students, Multiple) Students title url_title name Text surname Text
For the sake of this exercise I wanted to pull Robert’s team mates from Team 1 using the {siblings} tag. In particular, the players of Team 1 are: Robert, Paul, Mike, Harry, John
The problem I’m having is that if I use the channel parameter inside the {siblings} tag the results disappear: no output at all. The code is the following:
{exp:channel:entries channel="students" url_title="robert"}
{siblings field="players" channel="teams" backspace="6"}
{siblings:name}<\br>
{/siblings}
{/exp:channel:entries}
As soon as I remove the channel=”teams” bit (and use only the field parameter) everything is fine and the result is:
Paul Mike Harry John
The {parents} tag doesn’t give me the same problem, in fact the channel parameter works just fine. If I use the following code
{exp:channel:entries channel="students"}
{name} {surname}<\br>
{parents field="players" channel="teams" backspace="6"}
{parents:title}<\br>
{/parents}
{/exp:channel:entries}
Everything works just fine and the results are:
Robert Doe Team 1 Paul Miller Team 1 [...] etc.
I’m quite confused because the documentation (https://docs.expressionengine.com/latest/fieldtypes/relationships.html) says that also the siblings tag accepts all the standard parameters and the last example in The Community Sports League at the very end of the docs page makes use of the channel parameter inside the siblings tag - {siblings channel="seasons" field="games"}.
Any help in clarifying this thing would be appreciated. Thanks a lot in advance! 😊
P.S. After few more tests I noticed that the results are as expected also if I use channel=”students” in the {siblings} tag, but the documentation in the Community Sports League example tells me that the channel to use is the parent one, in my case ‘teams’. As to say: “pull all entries from the ‘students’ channel that are related to the parent channel ‘teams’ through the ‘players’ field, i.e. siblings”. At least this was my reasoning after reading the docs. Maybe I should assume there’s an error in the documentation?
P.P.S. I inserted backslashes into the < br > tags otherwise they would be parsed as line breaks also inside a code snipped. To be honest I don’t know how to avoid this…
Hi svedish, welcome back to ExpressionEngine!
Just to be clear, am I reading it correctly that you solved the problem?
As soon as I remove the channel=”teams” bit (and use only the field parameter) everything is fine and the result is: Paul Mike Harry John
And you’re just curious if the documentation or code has a bug?
Thanks for your answer Derek 😊
Well, more than just curious, I would like to be sure I understand this software properly while I progress through the documentation. And of course I would hope this thread could be useful to other people as well in the future.
As you can imagine, if a beginner like me stumbles upon something that doesn’t behave as expected (or at least as per how he reads and understand the instructions) he’s always left wondering if it’s him doing something wrong, if there is an error in the instructions or even a bug in the code. Of course, before raising an issue / bug ticket, I thought it would be wise to write in the forums first.
Just to be clear, I got to the solution just by chance, not because I grasped the logic behind the {siblings} tag. I tried this and that and just realised I had to remember to never use the parents channel as a tag in the {siblings} tag because it wouldn’t work as it said in the docs. In fact, as I was saying in my first post, in the last example of the EE documentation (starting from version 3 docs) the {siblings} tag makes use of the parent channel tag (channel=”seasons”) and so I tried to use the channel=”teams” parameter in my code since the teams channel is parent of the students channel. That didn’t show the expected results…
So, yes, please let me know if it’s just me not getting how this works properly or if there’s an error in the docs or even a bug in the code.
It is important in order to understand things properly, but it could also be important (just the first thing that pops into mind) in some cases if a child has more than one parent. What happens if I use the same relationship field to link few channels together and I have to discriminate by channel to pull the right {siblings}?
This is, actually, what brought me to the issue in the first place: I had used the same students (relationship) field to link both a classes and a teams channel (as parents) to the same students channel (child). In that case I wanted to discriminate using the channel parameter to pull the siblings of a student as class mates or the siblings of the same person as teams mates, given that the students were both part of classes and sports teams in this school.
Hoping to make sense, I thank you in advance for your time.
Hi again,
Just to add to what I was saying earlier, I’ve just read the tutorial by Robin Sowell about Relationships Fields (https://u.expressionengine.com/article/relationship-fields-the-pizza-shop-example). She uses the Pizza Shop example to illustrate the parents tag.
Towards the end of the article she says exactly what I said just earlier about discriminating by channel:
“The {parents} tag will pull entries that have the current Entry from the {exp:channel:entries} tag as a child through the field that you specify. If you use the same field group in multiple channels, you may want to also specify the channel. In this case, we’re passing it the specialty_pizzas field. It will look for all entries attached to any channel through the specialty_pizzas field that have the current Pizza entry as a child. In our case, specialty_pizzas is only used in the Stores channel and this will have the result of finding all Stores that currently have this Pizza available.”
I imagine I should be able do the same with siblings? But it’s doesn’t seem to work.
Thanks again.
I’ve not had any issues with filtering by channel in any of the relationship fields. If you’d like someone on our team to look at your installation for you you are welcome to put in a support ticket and we can help diagnose what may be going on or help correct your templates. If you have a reproducible bug that you can provide step by step directions to replicate, please file one so that a contributor can work on it. Thanks!
Hi Derek,
Thanks for your answer.
That’s odd. My channels structure is so simple, and I have replicated the same steps on a production server as well with the same results. Perhaps I should file a bug report? As for a ticket it looks like it would cost $199 and I am only just starting to study ExpressionEngine (I am not using it for any client work yet).
By the way, in the siblings tag, I am not saying that no channel parameter works, I am only saying that the children’s channel (the same of the exp:channel:entries tag) works, but the parent channel would produce no results. Can you confirm that you are having no problem when filtering the siblings results by one of the parent channels?
Thanks again.
Hi Derek,
I hope you are well.
Just following up on this issue to let you know that I opened an issue on GitHub (titled “Using parent channel in the {siblings} tag to filter results produces no output”) 12 days ago. Unfortunately it hasn’t been labeled or answered. I was just wondering is sooner or later I will get a feedback from someone? You know, at least to understand if it’s me getting the whole thing wrong or if there is effectively a bug in the code or an error in the documentation.
Thanks again for your time.
Hi svedish, no one on our team has had time to look at it yet, as it’s a rather complicated issue to reproduce, and is a low priority since the effect is minimal and already mitigated as you mentioned above. You could try to get some eyeballs from the community if you wish, but frankly even if it is a confirmed bug, I can’t imagine anyone making it a high priority to take time out of their day to fix immediately. The juice just isn’t worth the squeeze, as the phrase goes.
Hi Derek,
Frankly I think that everyone here is taking time out of their day to contribute, in a way or another. Hopefully someone will get back with some feedback sooner or later. At the end of the day, performing a fresh installation and reproducing the issue doesn’t really take that long: I’ve done it several times.
Ultimately, my hope is that ExpressionEngine, especially after this shift in it’s business model, will grow as solid and flawless as possible, both with regard to the code and the documentation - which, in the case of software, I reckon is an integral part of the product itself. I’m sure many people like me are curious about it and are considering to adopt it for future client work, but when it comes to studying and choosing a CMS, as you rightly point out, the juice definitely must be worth the squeeze! 😉
Thanks.
Hey Derek,
I understand what you mean and to be honest, the first thing I did, when I noticed this strange behavior, was to enable debugging and dig into the queries. Then I realized that my PHP skills were just not good enough to understand what was causing the problem.
At the end of the day, I’m a front end developer, and of course, as an old school guy, I got my hands dirty with many things over the years. This issue, however, requires some stronger back end skills, I’m sorry. It would be actually nice to be part of a community and contribute to a larger extent when you choose to adopt a product, especially an Open Source one, but I guess this can’t be the case.
Well, hopefully, someone in the future will have a look at this issue and I’ll find out if this was an expected behavior or a bug in the code.
Thanks for your time.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.