Be sure to register templates moved to module layer, and moving functions from template.php to module
Using FileMerge to compare (Mac OS X graphical diff), no differences between the page.tpl.php in the scf_base theme and the page.tpl.php I have in scf.module.
But the site doesn't look the same at all. That means the reason moving template files to the theme layer failed is because I am not calling them right.
Had to put them in hook_theme_registry, of course.
Once that was done, progress began in earnest. Breaking the site, of course.
Functions to rename, add to hook_theme functions (which means I don't actually have to find where they are called), are helpfully indicated with fatal errors, so long as I copy them to scf.module and don't rename.
Fatal error: Cannot redeclare phptemplate_truncate_by_word_count() (previously declared in /sites/scf-dev/profiles/scf/modules/scf/scf.module:549) in /sites/scf-dev/profiles/scf/themes/scf_base/template.php on line 473
(Of course, if we can, this special theming function will be replaced with something more Drupally.)
<?php
/**
* Trim the given string by the gven number of words. Create as an alternative
* to node_teaser() which truncates to utf8 character.
*
* @param $text
* The text being acted upon
* @param $words
* The number of words to truncate this string to
* @param $hellip
* Flag whether '...' should appear at the end of the string
* @return
* The resulting string
*/
function phptemplate_truncate_by_word_count($text, $limit = 120, $hellip = TRUE) {
$text = strip_tags($text);
$words = str_word_count($text, 2);
$pos = array_keys($words);
if (count($words) > $limit) {
$text = substr($text, 0, $pos[$limit]) . ($hellip ? '...' : '');
}
return $text;
}
?>
Comments
Post new comment