Recommended location for a php function to be used by a custom template in a Package

Permalink
Hi guys,

Where should functions needed by custom templates included in a package for blocks be placed in concrete 5.7?
As an example lets say I wanted to add a truncate text function for a custom template for the page list block, where should I place my function so its available in the view.php template?


Martin

 
JohntheFish replied on at Permalink Reply
JohntheFish
If you want to truncate text, there is already a text helper that does it.

Otherwise, create a class somewhere under package_name/src/ and instantiate the class.

You may need to read up on the autoloader so you can then load the class. Its finicky and has changed to become more so in 5.7.4.
martbase replied on at Permalink Reply
Thanks, the class in package_name/src/ is what I was looking for so I can have additional functionality in view templates whenever I need to. I will read/research some more especially on autoloader and then try it out.

Martin