In the Joomla-backend, there are much ways to filter the listview. Some are selectable by various dropdown-fields, others could be filtered by some keys written direct to the searchfield (inline-filters) - as:
id:nn (nn=article-id) title:xxxxxx (xxx=mating string to the article-title)
When working with Joomla in the backend, I find it extremely comfortable to have more matching possibilities like:
id1....6 can be any unique article ID.
This is useful, if your article have titles following name-conventions
If there are titles like this:
art_str-a_str-b_str-c_str-d you can list only articles
with str-a AND str-c (by title:str-a,str-c)
or str-b AND str-c (by title:str-b,str-c)
or str-c AND str-d (by title:str-c,str-d)
in its title
In all cases, the articles matching to the search-keys in the "comma separated" or the "area" list are shown in the listview.
They can be still combined with the other dropdown-filters.
In all ways, only the articles, matching to all active filters will be listed.
To build in this, there must be done this core-changes:
/administrator/components/com_content/models/articles.php
/administrator/languages/en-GB/en-GB.com_content.ini
-(change COM_CONTENT_FILTER_SEARCH_DESC for new description)
The result of the change will expand the search-inline-filters by:
**id:id1,id2,id3,... **for a comma separated article-list
id:id1-id99 for an article-list with ids in range from 1 to 99
Can be build into any act. Joomla-Version - (best in J4)
I'm running this changes in my one Joomla-environment under J3.9.20 and it works well.
In the add. files I have some screenshots to look to.
Is this wished to be build in into Joomla4?
Labels |
Removed:
?
|
Labels |
Added:
?
|
If you have the code then please submit a pr. It will have to be for J4 as it is a new feature and J3 is not taking any new features.
Thanks in advance
Category | com_content | ⇒ | com_content Feature Request |
Labels |
Added:
?
|
Hi guys,
after checking the basic-code in J4, I found that the db-access code is different to J3. So I must do some new codings and tests before setting up the code here. I'm working!
Before someone begin.
id:id1,id2,id3,... or id:id1-id99
this is okay
title:foo,bar
this is not good, it limits possibility to search title that contain the comma (or other symbol)
title:foo,bar
In this case we can do something like this:
title:foo,,bar
if the search goes to 'foo' AND ',bar'.
if the search goes to 'foo' AND ',bar'.
what if User want to search ,
or Foo, bar.
upd: if you meant use ,,
as separator it also not helps, User may want to search title where he has a typo with two ,,
.
In my experience such magic with text search, never works good.
Hi
is there any char that can not be used in the title of an article?
hm, can be absolutely anything that User able to copy/paste, I think.
One of possible idea, is to use another "prefix" for the complex search, where we can "say" that some symbols cannot be searched, something like:
title_query:foo,bar
search title with foo OR bar
title_query:foo&bar
search title with foo AND bar
In this case symbols , &
will not be possible to search with title_query:
prefix, but possible with title:
So existing title:foo, bar
will work as usual, will search for title with foo, bar
@SniperSister
Hello David, I found this post from you:
https://forum.joomla.de/thread/7807-joomla-db-api-frage-zu-prepared-statement-versus-plumpem-typecasting/?postID=53810#post53810
So I think you can help me.
I want to update the joomla inline-search in the article-view. For that I have made a test-solution in my J3.9.xx environment and it works well.
When transferring this to J4-Beta-x I found a new way to make the sql-queries as you described in that forum-post before.
Therewith I have some problems.
Let me explain:
In the search field I have this value:
id:1,3,5
That should show only the articles 1,3,5 in the listview.
It works well with this hardcoded code:
$query->where('(' .$db->quoteName('a.id') .' = :search0'
.' OR ' .$db->quoteName('a.id') .' = :search1'
.' OR ' .$db->quoteName('a.id') .' = :search2)')
->bind([':search0', ':search1', ':search2'], $array);
array is an array with this values:
Array ( [0] => 1 [1] => 3 [2] => 5 )
To make the code flexible, I have to generate the query by php, depending of the content in the search field.
For that I have this code:
$input = $db->escape(substr($search, 3)); //string from searchfield-pos3 into workfield and escaping
$array = preg_split('/(\.\s?|,\s?)/',$input, -1, PREG_SPLIT_NO_EMPTY); // create an array of the input-data
foreach($array as $key => $val)
{
if ($key == 0)
{
$qry = 'a.id = ' .$val;
$where = "\$db->quoteName('a.id') " .'= :search' .$key;
$bind = "':search" .$key ."'" ;
}
else
{
$qry .= ' OR a.id = ' .$val;
$where .= " OR \$db->quoteName('a.id') " .'= :search' .$key;
$bind .= ', ' ."':search" .$key ."'";
}
}
$qry contains the query for the earlier used sql-syntax.
&qry a.id = 1 OR a.id = 3 OR a.id = 5
$where contains the query-syntax for the new where-statement.
$where $db->quoteName('a.id') = :search0 OR $db->quoteName('a.id') = :search1 OR $db->quoteName('a.id') = :search2
$bind contains the query-syntax for the new bind-statement.
$bind [':search0', ':search1', ':search2']
Before execution, $bind must be more prepared to:
$bind .= '[' .$bind .'], $array';
Then setting up the query to:
$query->where('(' .$where .')')
->bind($bind);
When executing this code it results in an error:
Too few arguments to function Joomla\Database\DatabaseQuery::bind(), 1 passed in /var/www/web26859828/html/J4.0_Beta1/administrator/components/com_content/src/Model/ArticlesModel.php on line 511 and at least 2 expected
Note!: line 511 is the position where the "->bind($bind);" statement stays.
And now my question:
After experimenting now for to days I have no idea to locate the error.
Do you have any idea?
I'm a german guy, may be it it easier to discuss this in german.
@hgh-esn ->bind() needs at least two arguments: $key and $value, you are only passing one leading to the error.
You have two options here:
a) Multiple bind() calls:
Call bind() in each iteration of the foreach loop:
$query->bind(':search' . $key, $val)
b) One single bind() call:
Build an array of all keys and an array of all values:
$keys = [":search0", ":search1", ":search2"]; $values = ["value for 0", "value for 1", "value for 2"]; $query->bind($keys, $values);
Option a) is the cleaner one in my opinion
The right way is to use $query->whereIn()
if possible or if you want to bind array you can use $query->bindArray()
From the function description of whereIn()
https://github.com/joomla-framework/database/blob/4cda5d73eb55ac8a596f261aac08a33d658421fb/src/DatabaseQuery.php#L1859-L1876
this function uses internally the bindArray()
function
https://github.com/joomla-framework/database/blob/4cda5d73eb55ac8a596f261aac08a33d658421fb/src/DatabaseQuery.php#L1972-L1990
@high-esn have you abandoned this?
Hi Brian,
... have you abandoned this?
no I haven't, but I actually have less time to finish it. I have the basic
code running in my private Environment. But there is a lot of work to do to
make it saver by a better error handling in combination with the language
support.
If you or some other developer is interestet to have a look, let me know by
email. I will make an account to the environment possible.
greetings HGH
Sent by HGH Mobil
Gesendet mit der Telekom Mail App
https://kommunikationsdienste.t-online.de/redirects/email_app_android_sendmail_footer
--- Original-Nachricht ---
Von: Brian Teeman
Betreff: Re: [joomla/joomla-cms] [4.0][RFC] Make the search-filter in the
article-view more flexible (#30175)
Datum: 13. November 2020, 9:03
An: joomla/joomla-cms
Cc: hgh-esn, Mention
@high-esn have you abandoned this?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#30175 (comment)
, or unsubscribe
https://github.com/notifications/unsubscribe-auth/ABIN4DVHBFBCCDAEJQU42K3SPTR6JANCNFSM4PGBRDHQ
.
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2022-11-29 22:46:27 |
Closed_By | ⇒ | fancyFranci | |
Labels |
Added:
?
No Code Attached Yet
Removed: ? ? |
I'm closing this issue now, but feel free to provide your feature at https://github.com/joomla/rfc as soon as you have the motivation to work on that topic again :)
Add some screenshots.
This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/30175.