Skip to main content
added 18 characters in body
Source Link
Gareth
  • 1.6k
  • 2
  • 14
  • 35

I have a section of "video" entries which are related to another section via an "area" field in the "video" section. When you do a search on the front end by area then the related video displays as expected. What I also have in the area section is a text field full of postcodes, what I would like to happen is when you then do a search by postcode then the video displays that is related to that area, is that possible?

Here is my code that works for searches by area:

{% set query = craft.request.getParam('search') %}
{% set searchEntries = craft.entries.search(query).order('score') %}

{% for entry in searchEntries.video(':notempty:') %}
  {% set video = entry.video %}
  {{ video.embed({ width: 340, height: 191, showinfo: false }) }}
{% endfor %}

I have a section of "video" entries which are related to another section via an "area" field in the "video" section. When you do a search by area then the related video displays as expected. What I also have in the area section is a text field full of postcodes, what I would like to happen is when you then do a search by postcode then the video displays that is related to that area, is that possible?

Here is my code that works for searches by area:

{% set query = craft.request.getParam('search') %}
{% set searchEntries = craft.entries.search(query).order('score') %}

{% for entry in searchEntries.video(':notempty:') %}
  {% set video = entry.video %}
  {{ video.embed({ width: 340, height: 191, showinfo: false }) }}
{% endfor %}

I have a section of "video" entries which are related to another section via an "area" field in the "video" section. When you do a search on the front end by area then the related video displays as expected. What I also have in the area section is a text field full of postcodes, what I would like to happen is when you then do a search by postcode then the video displays that is related to that area, is that possible?

Here is my code that works for searches by area:

{% set query = craft.request.getParam('search') %}
{% set searchEntries = craft.entries.search(query).order('score') %}

{% for entry in searchEntries.video(':notempty:') %}
  {% set video = entry.video %}
  {{ video.embed({ width: 340, height: 191, showinfo: false }) }}
{% endfor %}
Source Link
Gareth
  • 1.6k
  • 2
  • 14
  • 35

Get search results by relationship

I have a section of "video" entries which are related to another section via an "area" field in the "video" section. When you do a search by area then the related video displays as expected. What I also have in the area section is a text field full of postcodes, what I would like to happen is when you then do a search by postcode then the video displays that is related to that area, is that possible?

Here is my code that works for searches by area:

{% set query = craft.request.getParam('search') %}
{% set searchEntries = craft.entries.search(query).order('score') %}

{% for entry in searchEntries.video(':notempty:') %}
  {% set video = entry.video %}
  {{ video.embed({ width: 340, height: 191, showinfo: false }) }}
{% endfor %}