How to create a global filter and use the same?

Can anyone give me an example to create a global filter and use it across all the templates. Thanks.