#15 Custom View Filters in CodeIgniter 4

แชร์
ฝัง
  • เผยแพร่เมื่อ 12 พ.ย. 2024

ความคิดเห็น • 18

  • @TheSoftwareServices
    @TheSoftwareServices 4 ปีที่แล้ว +1

    Great teaching sir, pl do Core PHP and OOPS Inheritance,Polymorphism, Abstraction, Encapsulation, Overidding Overloading....etc, it will be helpful to many.....

    • @GoPHP
      @GoPHP  4 ปีที่แล้ว

      Sure , GoPHP is planning the same

  • @kprakash9665
    @kprakash9665 3 ปีที่แล้ว +1

    SYSTEM FILE IS not generated if i install with composer installation command What is an alternate Option for it brother

  • @foxbille
    @foxbille 4 ปีที่แล้ว +2

    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

    • @GoPHP
      @GoPHP  4 ปีที่แล้ว

      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

    • @foxbille
      @foxbille 4 ปีที่แล้ว

      @@GoPHP Work fine !!!! You're fabulous, thank you very very much.

    • @JogeshKrishna
      @JogeshKrishna 3 ปีที่แล้ว

      @@GoPHP you are awesome:)
      works like magic..

  • @softwareEngineerKunwar
    @softwareEngineerKunwar 3 ปีที่แล้ว

    thank you for your video.

  • @vijaysrini27
    @vijaysrini27 4 ปีที่แล้ว

    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?

    • @GoPHP
      @GoPHP  4 ปีที่แล้ว +1

      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

    • @vijaysrini27
      @vijaysrini27 4 ปีที่แล้ว

      @@GoPHP Thanks.

  • @jasshhandrews1022
    @jasshhandrews1022 3 ปีที่แล้ว +1

    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

  • @kulasiriniit
    @kulasiriniit 4 ปีที่แล้ว +1

    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

    • @GoPHP
      @GoPHP  4 ปีที่แล้ว +2

      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...

    • @nipunsachinda
      @nipunsachinda 3 ปีที่แล้ว

      @@GoPHP 'hideNumbers' => '\CodeIgniter\View\Filters::hideNumbers' mothod is not found in directory.i used composer install.how do I change

    • @aaniqchagani5844
      @aaniqchagani5844 3 ปีที่แล้ว

      @@GoPHP Thanks

    • @JogeshKrishna
      @JogeshKrishna 3 ปีที่แล้ว +1

      @@GoPHP Yup I made the required changes in C:\xampp\htdocs\Project\vendor\codeigniter4\framework it works

  • @kulasiriniit
    @kulasiriniit 4 ปีที่แล้ว

    Thank you so much sir