Hi,
I try to theme a view and I use the node-view-viewname.tpl.php file.
When I display a cck field I want to trim its length to 300 characters and to keep the html tags correctly placed.
For this I use a custom function from a php site.
My problem is where to place that helper function. If i place it in the tpl.php file I get the error: " Call to undefined function truncateText() ... "
I tried to use if (!function_exists('truncateText')) { ... } pattern ... but now it displays the first entry and for the next one the function is undefined.
Does anyone knows a solution for this? In general if you need a new function in a tpl.php file in what file do you place it?
Do you know a function inside drupal api that does this job? I saw that views are using something like this to trim field length.
Thanks a lot,
Radu
Comments
Either place in the themes
Either place in the themes template.php file or I often make a simple helper module that contains useful functions.