4

I need a list of all entries filtered by a relationship field. I thought I might be able to use the search parameter: http://ellislab.com/expressionengine/user-guide/modules/channel/channel_entries.html#search-field-name, but it apparently only works on “Text Input”, “Textarea”, and “Drop-down Lists”.

I'm tempted to convert my relationship field to a Drop-down list and figure out another way to make the relationship between my channels. What are my options? Should I be using Category module somehow?

  • I think it would be helpful for you to explain in more detail what you are trying to do. I'm not sure what "I need a list of all entries filtered by a relationship field." means, and I use relationships quite a lot. Do you mean you want a list of all entries that have been marked as related to something else? – UltraBob Dec 4 '12 at 9:03
5

If you use Playa instead of the default relationship type, and make the field Searchable in the options, it will work as if it were a text type. But that doesn't work with the default Relationship fieldtype; you'll have to get Playa.

| improve this answer | |
  • What do you think about making my relationship just a simple drop down list? Or can I use the Category module somehow? – ExpressionEngineNewbie Dec 4 '12 at 6:05
  • You could do either of those things, certainly. I don't think either is an optimum solution. – adrienne Dec 5 '12 at 16:52
  • Anyone know if this is still true today? This answer is from 2012. – jthomas Jun 3 '14 at 20:00
4

Just wanted to add that the new version of Low Search allows you to filter entries by relationship (both native and Playa-based). Since Low Search extends the channel:entries class, you can pretty much use it as a replacement with the added features. In addition the searching and filtering is much faster as it uses FULLTEXT indexes.

Another option as mentioned by adrienne is to use Playa and search the text that's stored in exp_channel_data. I'd recommend using the 1entry_id1 when searching though, because Playa doesn't update the title text that's stored there when the child entry is updated. The entry_id is store like [123] This is the title, so you could search for [123]. Keep the square brackets so that you don't accidentally match something like [2123] when searching for 123.

| improve this answer | |
0

You don't really say what your trying to accomplish, so I can't say if this is recommended advice, but 'yes'. Yes, it's possible to just use a text field as the basis of a relationship, if you aren't afraid of doing custom queries.

We've done this in a number of situations. Generally, speaking using the relationship field type or Playa works for us, but every once in awhile, a search:in or custom query performs better.

One example, for use, we needed to be able to display all multilingual versions of a publication. The client, produces publications, not all publications are translated, and not all languages are completed when translation occurs, plus occasionally publications are translated into random languages.

So a publication could have an English, Chinese, Spanish, Vietnamese, or Korean version (the five standards), but occasionally may have a Russian, Hmong, or other language translation as well.

We made the relationship field, a text field that already exist, PubID. This field exist to correlate the web version of the publication to the print version, but any version of the publication got the id.

We have six language channels— english, spanish, chinese, korean, vietnamese, and other. We're using a custom query, since the system was set-up pre-search:in days, but basically the query just looks for the current PubID across all six channels, returns the channel name. A subquery is then executed if the channel name is 'other', to pull the results from the specified language field.

So whatever version of the publication a user is viewing, a listing of all the other languages it is available in is provided, and the client doesn't have to keep an updated language list, they just publish the new version, when and if it's ever translated.

So that's a rather long statement to say, 'yes' if the situation warrants it, it is doable, but make sure doing it, makes life easier for the project/client.

| 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.