FAQ | This is a LIVE service | Changelog

Skip to content
Snippets Groups Projects
Commit de1a85f9 authored by Chris Wilkinson's avatar Chris Wilkinson
Browse files

Merge pull request #14 from thewilkybarkid/smart_trim

Use Smart Trim in teasers
parents c81e93be fea53f25
No related branches found
No related tags found
No related merge requests found
......@@ -47,6 +47,7 @@ dependencies[] = pathauto
dependencies[] = raven
dependencies[] = realname
dependencies[] = redirect
dependencies[] = smart_trim
dependencies[] = token
dependencies[] = transliteration
dependencies[] = views
......
......@@ -57,6 +57,36 @@ function cambridge_install() {
field_create_instance($instance);
}
// Use the Smart Trim module for teasers.
$smart_trimmed = array(
'label' => 'hidden',
'module' => 'smart_trim',
'settings' => array(
'more_link' => 0,
'more_text' => 'Read more',
'summary_handler' => 'full',
'trim_length' => 325,
'trim_options' => array(
'text' => 'text',
),
'trim_suffix' => '...',
'trim_type' => 'chars',
),
'type' => 'smart_trim_format',
'weight' => 0,
);
foreach (array('page', 'link') as $type) {
$instance = field_info_instance('node', 'body', $type);
foreach (array('teaser', 'news_listing_item', 'vertical_teaser', 'sidebar_teaser') as $mode) {
$instance['display'][$mode] = $smart_trimmed;
}
field_update_instance($instance);
}
// Force a main-menu link on Basic Pages.
variable_set('menu_force_page', TRUE);
......@@ -291,3 +321,61 @@ function cambridge_update_7102() {
throw new DrupalUpdateException('Failed to enabled Metatag modules');
}
}
/**
* Use the Smart Trim module for teasers rather than Drupal's native trimming.
*/
function cambridge_update_7103() {
if (module_exists('smart_trim')) {
return;
}
if (FALSE === module_enable(array('smart_trim'))) {
throw new DrupalUpdateException('Failed to install Smart Trim module');
}
$smart_trimmed = array(
'label' => 'hidden',
'module' => 'smart_trim',
'settings' => array(
'more_link' => 0,
'more_text' => 'Read more',
'summary_handler' => 'full',
'trim_length' => 325,
'trim_options' => array(
'text' => 'text',
),
'trim_suffix' => '...',
'trim_type' => 'chars',
),
'type' => 'smart_trim_format',
);
foreach (array('page', 'link') as $type) {
// Make sure the body appears trimmed in teasers.
if (FALSE === node_type_get_name($type)) {
// Content type no longer exists.
continue;
}
$instance = field_info_instance('node', 'body', $type);
foreach (array('teaser', 'news_listing_item', 'vertical_teaser', 'sidebar_teaser') as $mode) {
if (
$instance['display'][$mode]['label'] !== 'hidden'
||
$instance['display'][$mode]['type'] !== 'text_summary_or_trimmed'
||
$instance['display'][$mode]['settings']['trim_length'] !== 600
) {
// Display has been changed, so don't touch it.
continue;
}
$instance['display'][$mode] = array_merge($instance['display'][$mode], $smart_trimmed);
}
field_update_instance($instance);
}
}
......@@ -55,6 +55,9 @@ projects[redirect][subdir] = "patched"
projects[redirect][patch][] = "http://drupal.org/files/redirect-prevent_circular_redirects-1817976-42.patch"
projects[rules] = "2.6"
projects[scheduler] = "1.2"
projects[smart_trim][version] = "1.4"
projects[smart_trim][subdir] = "patched"
projects[smart_trim][patch][] = "http://drupal.org/files/issues/smart_trim_remove_punctuation_from_end_of_truncated_output-2169583-3.patch"
projects[tac_lite] = "1.2"
projects[transliteration] = "3.2"
projects[varnish][version] = "1.0-beta2"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment