User login

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;
}
?>

Resolution

Searched words: 
template files in theme layer

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • You can use Markdown syntax to format and style the text. Also see Markdown Extra for tables, footnotes, and more.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <blockquote> <small> <h2> <h3> <h4> <h5> <h6> <sub> <sup> <p> <br> <strike> <table> <tr> <td> <thead> <th> <tbody> <tt> <output>
  • Lines and paragraphs break automatically.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.