Search

hello I have a very simple section like this

  • Title (textimput)
  • Author (textimput)
  • Tags (textarea)

with data like:

data1

  • Title: This is my title
  • Author: Taylor Smith
  • Tags: religion, science, food

data2

  • Title: This is my title
  • Author: Taylor Smith
  • Tags: science

data3

  • Title: This is my title
  • Author: Twain Mark
  • Tags: food, religion

data4

  • Title: This is my title
  • Author: Taylor Smith
  • Tags: food, religion

how can I make a filter to select all the entries with 'taylor' in author fiels and 'religion' and 'food' in the tags field ???

thnx for the answers cheers g

(Edit: formatting edited by nickdunn)

Do you want to filter Data Source or entry list on administration pages?

data source

First try with static values. In your data source filter enter plain text. So in the Author filter try adding the text "Taylor Smith", and the tag field add "religion, food". When that data source is attached to a page do you see the correct results? If so, good, you can now replace these with parameters. Replace the author filter with {$url-author} and the tag filter with {$url-tags} and then call your page like:

/your-page/?author=Taylor Smith&tags=religion, food

Two things that might be tripping you up: if "author" is an Author field type then these can be filtered by author username or author ID only. So if Taylor Smith's username is "taysmith" then you should use this to filter and not the full name. Secondly, if you use two filters these combine to be both required. So if you are filtering on both author and tags, it will only find entries where both of these are matched (in the above example, entries 1 and 4 only).

I need something more powerful I want filter also if I search "religion" only I think I have to use regexp:{$url-tags} regexp:{$url-author} BUT if insert only ony of this I have an error form mysql and if I insert both I have and empty result

I need something really easy like WHERE author LIKE '%author%' AND tags LIKE '$religion$' but it cannot obtain this easy query....

You can use regex in a data source filter, but you need to use a particular syntax. Read the tutorial on filters. Regex is not my strong suit, so I'll let someone else intercede with an appropriate pattern if you need help with that.

The syntax Nick gave you for matching tags is good. The comma acts as a union (boolean OR) operator, so filtering on religion, food means "return entries matching "religion" OR "food"). If you wanted to use AND instead, you would use the plus sign as a delimiter.

tnx to all for the answers

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details