We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Relationships: show relationships between two things that are not siblings

How Do I?

SPC-Lesli's avatar
SPC-Lesli
30 posts
8 years ago
SPC-Lesli's avatar SPC-Lesli

Hi all,

I have a site that currently uses Playa (for the relationships/Related Entries. I’m looking at upgrading, and wanted to see how I would use the Relationship tag in EE for these relationships. I don’t know quite how I can manage that, though…

Example: A purple shimmer eyeshadow is part of a collection. So it would be related to the collection, and a sibling to all other items in that collection. So far, okay. But now I want to post links to other similar eyeshadows from other collections. They’re eyeshadows from other vendors that are similar to this one. They’re not from the same vendor, they’re not from the same collection. So…how would I display a link to these other “related entries” of my choosing?

I =do= want to: link to up to five other items that are simlar to this item: either its parent collection, OR its children (if it’s a collection or an item in a kit); and other highly similar items from other vendors.

I =don’t= want to: link to any or every other eyeshadow that is also purple and or shimmery.

Here’s an entry with links to related items, relationships created using Play and tags created using Solspace Tag module. Currently, I have to designate related entries for each individual entry - which lets me keep things very specific.

http://www.sparklecrackcentral.com/such/obsessive/addictions/fyrinnaes_biker_chic

       
Derek Jones's avatar
Derek Jones
7,561 posts
8 years ago
Derek Jones's avatar Derek Jones

How are you currently specifying the relationship with Playa? It sounds like these other entries are manually curated with a separate “related interest” field? If that’s the case, then the native relationships definitely have you covered and will be more performant than Playa.

       
SPC-Lesli's avatar
SPC-Lesli
30 posts
8 years ago
SPC-Lesli's avatar SPC-Lesli

Currently I’m not associating the entries in Playa at all, other than selecting individual entries to be related to other individual entries. (I know that I was using a small amount of Playa’s capabiilties, but…that’s what worked for me.) I wasn’t entirely sure that the native EE relationships tag would do what I wanted it to, but it appears that it will work. Thanks!

…now to figure out if/how I can replace the functionality of the Tag module - just so that I can use the basic EE functionality to its fullest…

       
Derek Jones's avatar
Derek Jones
7,561 posts
8 years ago
Derek Jones's avatar Derek Jones

Options for Tag depend on how you’re using it / what you need in terms of taxonomy. That said, Tag is compatible with ExpressionEngine 3 so there’s no need to move away from that solution if you don’t want to.

       
SPC-Lesli's avatar
SPC-Lesli
30 posts
8 years ago
SPC-Lesli's avatar SPC-Lesli

I’ve added a Relationships field to my channel’s fieldset, and now…I’m trying to figure out how to code it into my templates. The examples are for parents or siblings…not for the entries that I’ve chosen. I’m not sure which example to follow?

       
Derek Jones's avatar
Derek Jones
7,561 posts
8 years ago
Derek Jones's avatar Derek Jones

The channel entry that sets the relationship is the “parent”, and the “related interest” entries are the children, so you can just use the relationship field’s name as a pair like this.

       
SPC-Lesli's avatar
SPC-Lesli
30 posts
8 years ago
SPC-Lesli's avatar SPC-Lesli

Except all of these entries are in the same channel. (It has never made sense to me to break all of my content up into different channels, so…I don’t.) There are no parents, there are no children. All siblings…kind of.

I think I need to use a combination of the Multiple Entries that you just showed me, and…some siblings syntax?

       
Derek Jones's avatar
Derek Jones
7,561 posts
8 years ago
Derek Jones's avatar Derek Jones

Doesn’t matter if it’s the same channel, you still have a parent (entry) / child (related items) relationship. Siblings are all of the child related items of a given parent.

       
SPC-Lesli's avatar
SPC-Lesli
30 posts
8 years ago
SPC-Lesli's avatar SPC-Lesli

I have my template working, I have entries related (by me manually choosing specific entries in the Related Entries field), I have the template displaying the images/links like I want…but I’m not seeing the entries I manually chose to be related. I’m seeing many more entries, and I’m not 100% sure how they’re being chosen.

Here’s the code I have in my template:

...lots of other template code, omitted for brevity...

{siblings field="related_entries" limit="15" orderby="random" status="open|Featured"}
      <figure><a href="http://{url_title_path=" rel="noopener canonical" target="_top">http://images.sparklecrackcentral.com/clear.gif</a>

      <figcaption><a href="http://{url_title_path=" rel="noopener canonical" target="_top">{siblings:title}</a></figcaption></figure>
{/siblings}

I read through the documentation, but I don’t understand how to limit the displayed siblings, to ONLY the entries that I manually selected as related, in the CP Entry form’s Related Entries field.

       
Derek Jones's avatar
Derek Jones
7,561 posts
8 years ago
Derek Jones's avatar Derek Jones

Please see my response and link above. You are not looking for siblings, you are looking for children, so you would just use the relationship field’s normal variable tag pair.

       
SPC-Lesli's avatar
SPC-Lesli
30 posts
8 years ago
SPC-Lesli's avatar SPC-Lesli

It looks like you say that I should use the relationship_field tag pair instead of the siblings tag pair. So I tried switching that in my template code: (and my template code is not rendering right in this field…)

<div id="related">{relationship_field field="related_entries" limit="15" orderby="random" status="open|Featured"}
      <figure><a href="http://{url_title_path=%27obsessive/addictions%27}" rel="noopener canonical" target="_top">http://images.sparklecrackcentral.com/clear.gif</a>

      <figcaption><a href="http://{url_title_path=%27obsessive/addictions%27}" rel="noopener canonical" target="_top">{relationship_field:title}</a></figcaption></figure>
{/relationship_field}</div>

But now the display of related entries is working…even less well than before. I’m not seeing any of the related entries that I chose.

http://www.sparklecrackcentral.com/such/obsessive/addictions/concrete_minerals_flame_collection_kit

       
Derek Jones's avatar
Derek Jones
7,561 posts
8 years ago
Derek Jones's avatar Derek Jones

What is the name of your relationship field? Is it related_entries?

       
SPC-Lesli's avatar
SPC-Lesli
30 posts
8 years ago
SPC-Lesli's avatar SPC-Lesli

Yes, the field name of my relationship field is

related_entries

When I used the above code in my template, but used the siblings tag pair (instead of the

relationships

tag pair), I saw images and titles and links to related entries. Except…it wasn’t ONLY the related entries that I’d manually chosen in the Related Entries field, but almost every other entry in that channel that started with the name “Concrete Minerals”. Which is not what I want.

       
Derek Jones's avatar
Derek Jones
7,561 posts
8 years ago
Derek Jones's avatar Derek Jones

Give this a shot. Notice that the tag pair uses the field name itself. Please refer to the link in the documentation above as well for prefixing the related entries’ variables within the field’s tag pair.

<div id="related">
 {related_entries limit="15" orderby="random" status="open|Featured"}
  <figure>
   <a href="http://{related_entries:url_title_path=%27obsessive/addictions%27}" rel="noopener canonical" target="_top">http://images.sparklecrackcentral.com/clear.gif</a>

   <figcaption>
    <a href="http://{related_entries:url_title_path=%27obsessive/addictions%27}" rel="noopener canonical" target="_top">{related_entries:title}</a>
   </figcaption>
  </figure>
 {/related_entries}
</div>
       
SPC-Lesli's avatar
SPC-Lesli
30 posts
8 years ago
SPC-Lesli's avatar SPC-Lesli

That did it! I was reading the documentation, but was just using the example code pretty much as-is. I wasn’t understanding that I needed to substitute in my related-entries field name.

       
1 2

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.