Great teaching sir, pl do Core PHP and OOPS Inheritance,Polymorphism, Abstraction, Encapsulation, Overidding Overloading....etc, it will be helpful to many.....
Very interesting ! Thank you, this helps a lot ! but what if a new version of CI4 is coming ? every thing will be lost. Like we used to do in CI3 for models, isn't it possible to put the new custom filter in a file located in app/ directory and named MY_Filters ... so that it can "survive" to further CI upgrades ? Eric
Yes, we can keep our filters into a separate folder, it is possible 1.create folder with name Viewfilters or MY_Filters in App folder: \App\Viewfilters 2. create class with name Filters and save it in Viewfilters folder. find the code below namespace App\Viewfilters; class Filters { public static function hideNumbers(string $value, int $display = 4): string { $txt = ''; for($i = 0; $i < strlen($value); $i++) { if($i < $display) { $txt .= $value[$i]; } else { $txt .= "X"; } } return $txt; } } 3. open view.php from the location App\Config\View.php and find the array public $filters = [ ] please update the path of your filter here like: public $filters = [ 'hidenumbers' => '\App\Viewfilters\Filters::hideNumbers', 'someother' => '\CodeIgniter\View\Filters::countVowels', ]; 4. in view file apply your filter Mobile: {mobile|hidenumbers(4)} Save all the work and please check I will prepare a small video for this and I'm going to update here Thank You Eric
When how do you pass more than two variables in a filter. E.g you showed how to display 6 digits. But suppose, we want to display 6 digits and the remaining with a '*' instead of an 'X' (which should be our choice dynamically), how do we do that?
Vijay, I have checked the manual and other resources as well, as of now I found, we can pass one parameter only, like: hidenumbers(2). if I found any, I'll update you Vijay
HI Gophp, When I'm trying to pass variable as 6 in hidenumbers it is showing complete mobile number, it is not hiding last 6 numbers public function hideNumber(string $value, int $display = 4): string { $txt = ''; for($i = 0; $i
Sir System Folder is not in my folder structurer in ci4 how can i setup that?. Simply can we Copy and past sytem folder from the Original Downloaded folder. is it correct way
how did you install? Manual or Composer if you did composer installation, no need to download system folder. it will available in C:\xampp\htdocs\Project\vendor\codeigniter4\framework if you did manual installation, System folder will download automatically please check...
Great teaching sir, pl do Core PHP and OOPS Inheritance,Polymorphism, Abstraction, Encapsulation, Overidding Overloading....etc, it will be helpful to many.....
Sure , GoPHP is planning the same
SYSTEM FILE IS not generated if i install with composer installation command What is an alternate Option for it brother
Very interesting ! Thank you, this helps a lot !
but what if a new version of CI4 is coming ? every thing will be lost.
Like we used to do in CI3 for models, isn't it possible to put the new custom filter in a file located in app/ directory and named MY_Filters ... so that it can "survive" to further CI upgrades ?
Eric
Yes, we can keep our filters into a separate folder, it is possible
1.create folder with name Viewfilters or MY_Filters in App folder: \App\Viewfilters
2. create class with name Filters and save it in Viewfilters folder. find the code below
namespace App\Viewfilters;
class Filters {
public static function hideNumbers(string $value, int $display = 4): string
{
$txt = '';
for($i = 0; $i < strlen($value); $i++)
{
if($i < $display)
{
$txt .= $value[$i];
}
else
{
$txt .= "X";
}
}
return $txt;
}
}
3. open view.php from the location App\Config\View.php and find the array
public $filters = [ ]
please update the path of your filter here like:
public $filters = [
'hidenumbers' => '\App\Viewfilters\Filters::hideNumbers',
'someother' => '\CodeIgniter\View\Filters::countVowels',
];
4. in view file apply your filter
Mobile: {mobile|hidenumbers(4)}
Save all the work and please check
I will prepare a small video for this and I'm going to update here
Thank You Eric
@@GoPHP Work fine !!!! You're fabulous, thank you very very much.
@@GoPHP you are awesome:)
works like magic..
thank you for your video.
When how do you pass more than two variables in a filter. E.g you showed how to display 6 digits. But suppose, we want to display 6 digits and the remaining with a '*' instead of an 'X' (which should be our choice dynamically), how do we do that?
Vijay, I have checked the manual and other resources as well, as of now I found, we can pass one parameter only, like: hidenumbers(2).
if I found any, I'll update you Vijay
@@GoPHP Thanks.
HI Gophp,
When I'm trying to pass variable as 6 in hidenumbers it is showing complete mobile number, it is not hiding last 6 numbers
public function hideNumber(string $value, int $display = 4): string
{
$txt = '';
for($i = 0; $i
Sir System Folder is not in my folder structurer in ci4 how can i setup that?. Simply can we Copy and past sytem folder from the Original Downloaded folder.
is it correct way
how did you install? Manual or Composer
if you did composer installation, no need to download system folder. it will available in C:\xampp\htdocs\Project\vendor\codeigniter4\framework
if you did manual installation, System folder will download automatically
please check...
@@GoPHP 'hideNumbers' => '\CodeIgniter\View\Filters::hideNumbers' mothod is not found in directory.i used composer install.how do I change
@@GoPHP Thanks
@@GoPHP Yup I made the required changes in C:\xampp\htdocs\Project\vendor\codeigniter4\framework it works
Thank you so much sir