How to add a new filter

Verze:

18. 07. 2025

Zodpovědná osoba:

Dominik Šlechta

Poslední aktualizace:

18. 07. 2025, kocandajan488@gmail.com

Adding a nette filter

When in need of adding a nette filter, if, for example, there is a missing filter or you need an entierly new, follow this process:

  1. Code or copy the filter to /app/filters/
    • If you're adding a missing filter, copy the contents of the filter from corresponding wiki page. Most of the filters should be found here: Nette filters
  2. In config.neon search for Filters\. There should be something like this
    - Filters\Elixir(%wwwDir%)
    - Filters\ImageExist(%wwwDir%)
    - Filters\Background(%wwwDir%)
    - Filters\GradientBackground(%wwwDir%)
    - Filters\MakePhoto(%wwwDir%)
    - Filters\FileInfo(%wwwDir%)
    - Filters\Watermark(%wwwDir%)
    - Filters\FlattenPhotos
    - Filters\Link
    and add another line that should look like this
    - Filters/YourFilterName
  3. Stay in config.neon, search for nette.latteFactory and in setup add another like looking like this
    - addFilter('invokeName', @Filters\YourFilterName)
    
    where invokeName is how you call the filter from latte files and should be in camelCase