1

I have a relationships field which pulls in from two channels: Posts and Programs. When the client is creating a page, this field enables them to manually relate the page to a number of blog posts and nonprofit programs, which appear in a "Related Content" section.

But EE 2.8's Relationships field only shows the title of an entry in the relationship picker. If a Post and a Program have similar titles or the same title, there seems to be no way for the client to know which is which.

Has anyone found a solution or workaround for this?

I've sort-of found a workaround using Playa, but it's not great. Playa is an addon for managing relationships. It allows relations to multiple channels and its related entry picker does let you filter by channel. Unfortunately...

  1. It requires several clicks to start filtering by channel
  2. While it lets you filter by one channel at a time, you have to keep switching the filter back and forth to select multiple entries from different channels.
  3. Once you've picked relationships and they appear in the right column, there's no indication of which channel they came from.

I'm new to EE, but I could imagine creating an addon which simply overrides the output of the Relationships picker to show something like <channel_name>: <title> instead of <title>.

  • This is a great idea, however, I don't think there is a hook in the right place in the relationship fieldtype to allow this type of override. It'd certainly be a great feature request that you may want to email EllisLab about. Since there's no hook, you would have to handle this with some JavaScript or built your own frontend to the fieldtype. – Jeremy Gimbel Mar 21 '14 at 23:43
  • Depending on the situation I often create several relationship fields, such as Related blogs, Related products, Related events.. you get the idea. This makes selection easier for the author. – Bluedreamer Mar 25 '14 at 18:13
  • @Bluedreamer I've considered that, but the client is keen on being able to manually order the list, which I think means I'm limited to a single relationships field. – Steve Grossi Mar 25 '14 at 18:20
0

I ended up solving this with a small patch to two EE core files. First, I have the relationships fieldtype query select the name of the channel:

// system/expressionengine/fieldtypes/relationship/ft.relationship.php:339
// Old
->select('channel_titles.entry_id, channel_titles.title')
// New
->select('channel_titles.entry_id, channel_titles.title, channels.channel_title')
->join('channels', 'channel_titles.channel_id = channels.channel_id')

Then I output the channel title before each listing in the relationships picker:

<!-- system/expressionengine/fieldtypes/relationship/views/publish.php:34 -->
<!-- As the first line within the <label> -->
<?= $row['channel_title'] ?>:

Now, when an admin sees two entries both called "Something Awesome" in the relationship picker, they'll know which is which:

posts and programs with the same name

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.