I would like to alter the output throughout my Codeigniter-based website.
Quite simply I would like to do
$output = str_replace(
array('ā','ē','ī','ō','ū','Ā','Ē','Ī','Ō','Ū'),
array('a','e','i','o','u','A','E','I','O','U'),
$output
)
In the event that the user prefers so.
By reading questions and answers here, I found a link that could help..
https://www.codeigniter.com/user_guide//general/controllers.html#processing-output
..but it only works controller by controller and that would be repetition of content.
Is there a way to make a hook instead?
Thanks in advance!
Right, so you can write a replace value in an extension of the loader class and save it as MY_Loader.php in application/core. Here is an example:
You may not need all of this, but I just copied it from an archived projects. Notice in the _ci_load() function you can affect the output before it is evaluated (normally an include as indicated by the comments but changed to string for your case). I have not tested this so it's not intended to be a solution as much as it is a general reminder that you can extend core classes and modify output in one place.
Of course, it might be easier to do in the output class itself: https://www.codeigniter.com/user_guide/libraries/output.html
In the application/Libraries file you can make a php file in which you can write something like this:
Then you can call it from wherever you want as a library.
If your intention is to replace accented characters then i suggest you take a look at wordpress remove_accents function here.
2) take a look at codeigniter hooks, there is display_override hook
3) once you define a function/class for this hook, you could get output string there
and then you can change the output as you like...