151 Posts
jimenaes
1 year ago
1
Topic

hello
I just paid for the Search Join extension but I can't find how to use it correctly. I have two content types. In a field of the first I can save the id of an article created with the second content type. I just want to create in the search type of the first content type a dynamic field that shows the titles of the second content type that are found in the table of the first content type (only those that do appear in the first content type table) in order to filter the articles of the first content type relating to the second content type. Can someone help me please?

Thanks

Get a VIP membership
1 year ago
0
Level 1

Hi jimenaes,

I don't think you need a search join field for this :

You need to create a select dynamic field with the exact same storage as the one you use to link content 2 in your content 1 form.

Set the query option to 'Free' and the SQL Query to :

SELECT id AS value, title AS text FROM #__content WHERE id IN ( SELECT DISTINCT(content_2_id) FROM #__cck_store_form_content_1 ) WHERE state = 1 ORDER BY text

Let's assume :

  • #__cck_store_form_content_1 is your content 1 specific table as content_1 is the name of your content type
  • content_2_id is the column where your content 1 form field stores the linked content 2 id
  • you only want published articles, so 'state = 1' is in the SQL query
  • you want to order the list of content 2 articles by title, so 'ORDER BY text' is here, as text is an alias of the title column in this query

Query not tested but it should do the trick

Get a VIP membership