Dealing with route (universal search) |
Do you have way to deal witch search on your site with segemnts.
Example: Exist database with three fields: priority, date, user, info Later I want to enter URL "www.mysite.com/20230815/jack" and I now that will start seach in my databes date 2023-08-15 and jack and throw in my table. As you see priority is not taken into consideration at this time of seach. Thx for your suggestions. Maybe something like this: www.mysite.com/date_20230815/user_jack And then I can $uri->getSegments(); and process witch example regex to catch colums to search. Is this OK?
You can use "www.mysite.com/20230815/jack" with the defined routes.
See https://www.codeigniter.com/user_guide/i...ting-rules
Sorry. I have read this but I dont had idea how to check for omitted data in segment.
Something like: In my project www.mysite.com/20230810/empty/jack And for real will be www.mysite.com/20230810/jack In this case as I now 3th segment will be treated as 2nd segment, but I dont want that.
I think I understand what you're talking about. In this case, I would recommend having default values in the URL. For example, https://www.mysite.com/_low_/20230815/jack/_info_ where __low_ is the default priority, _info_ is the information if it is not set.
Or you can create several rules for each case when some parameter is missing. Replace it with the default string. You need to check this solution, I can't say right now. PHP Code: <?php PHP Code: <?php PHP Code: $routes->get('(:num)/(:segment)', 'Home::index/$1/$2'); Navigate to http://localhost:8080/20230810/jack
Ozornik: https://forum.codeigniter.com/showthread...#pid411843
Good idea. Thanks to you I see another solution. By default segment may be "any" or other word couse searching all result in database on specific column. Example www.mysite.com/any/low/any/jack kenjis: https://forum.codeigniter.com/showthread...#pid411846 I dont understand what you whant to explain with this example.
I showed how to use the URL that you want.
|
Welcome Guest, Not a member yet? Register Sign In |