24 Posts
Liggie
1 year ago
5
Topic

I hope anyone can point me in the right direction. I have a search form which searches in multiple contenttypes. 
However I would like the possibility to search in all contenttypes (by default) and only in a few selected. It would be best when this goes automatically based on the usergroup. But I would be very much helped already when a user can filter the results based on contenttype.

So by default it searches in contenttyp: A, B and C.

My user should be able to search only in A and B, or A and C, or A and so on. (Preferably automatically selected based on their usergroup)

Get a VIP membership
24 Posts
Liggie
1 year ago
1
Level 2

Thank you very much! I'm going to try this.

24 Posts
Liggie
1 year ago
0
Level 3

I have bought the code pack. And I have added a field before search in my list and search form. I have added the code: $user = JFactory::getUser(); $groups = JAccess::getGroupsByUser($user->id); var_dump($groups); It looks like this retrieve the usergroups. And after this I feel lost. How do I populate the core content type based on the usergroup? 

1 year ago
1
Level 1

Hello Liggie,

for exemple with the native SEBLOD Article Manager, and you want to modify the Category Filter: 

In the Before Search script, you can dump the variable $fields.

You will see something like that: 


If you dump the field $fields['search']['art_catid'], you can see the property "Form": 


So, you can construct the form here.

If you are using a Select Simple, by default, add all cases in the select, and then depending on groups, you can remove unwanted options with something like that:

if ( ... ) {
	$fields['search']['art_catid']->form 	=	' aaa '
} elseif ( ... ) {
	$fields['search']['art_catid']->form 	=	' bbb '
} else....

Hoping it will help.

Regards.

24 Posts
Liggie
1 year ago
0
Level 2

Again a step in the right direction (I think....). Thanks for that. Could you please help me again? I feel like I'm almost there. But I lack the programming knowledge. 

I have the following in before search: array(24) { [0]=> object(stdClass)#2930 (1) { ["title"]=> string(14) "Abonnees basis" } [1]=> object(stdClass)#2933 (1) { ["title"]=> string(26) "Abonnees Diervoeders basis" } [2]=> object(stdClass)#2322 (1) { ["title"]=> string(25) "Abonnees Diervoeders plus" } [3]=> object(stdClass)# 


Now I need to filter the field core content type (select dynamic) based on the strings above. For example "Abonnees basis" has to be able to search in "wetgeving". I have completed the complete code it renders from beforesearch.



Get a Book for SEBLOD