? 16161_read_more_tweak.patch ? d7_edit_own_comments.patch ? sites/default/files ? sites/default/settings.php Index: modules/node/node.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/node/node.admin.inc,v retrieving revision 1.24 diff -u -p -r1.24 node.admin.inc --- modules/node/node.admin.inc 19 Jul 2008 19:04:24 -0000 1.24 +++ modules/node/node.admin.inc 28 Aug 2008 12:41:19 -0000 @@ -47,6 +47,14 @@ function node_configure() { '#description' => t('Must users preview posts before submitting?'), ); + $form['node_read_more_position'] = array( + '#type' => 'radios', + '#title' => t("Position of 'Read more' link"), + '#default_value' => variable_get('node_read_more_position', NODE_READ_MORE_INLINE), + '#options' => array(NODE_READ_MORE_INLINE => t('Inline with teaser'), NODE_READ_MORE_AS_LINK => t('Below the teaser')), + '#description' => t("Where should the 'Read more' link be placed? Inline, at the end of the teaser, or together with the other links below the teaser."), + ); + $form['#validate'] = array('node_configure_validate'); return system_settings_form($form); Index: modules/node/node.module =================================================================== RCS file: /cvs/drupal/drupal/modules/node/node.module,v retrieving revision 1.972 diff -u -p -r1.972 node.module --- modules/node/node.module 21 Aug 2008 19:36:37 -0000 1.972 +++ modules/node/node.module 28 Aug 2008 12:41:19 -0000 @@ -46,6 +46,16 @@ define('NODE_BUILD_RSS', 4); define('NODE_BUILD_PRINT', 5); /** + * 'Read more' link is placed inline at the end of the teaser. + */ +define('NODE_READ_MORE_INLINE', 0); + +/** + * 'Read more' link is placed with the other links. + */ +define('NODE_READ_MORE_AS_LINK', 1); + +/** * Implementation of hook_help(). */ function node_help($path, $arg) { @@ -135,6 +145,9 @@ function node_theme() { 'node_submitted' => array( 'arguments' => array('node' => NULL), ), + 'node_read_more_link' => array( + 'arguments' => array('node' => NULL), + ), ); } @@ -1053,6 +1066,10 @@ function node_view($node, $teaser = FALS $content = drupal_render($node->content); if ($teaser) { $node->teaser = $content; + // Check whether there is more to read, then add the 'Read more' link. + if (!empty($node->readmore) && variable_get('node_read_more_position', NODE_READ_MORE_INLINE) == NODE_READ_MORE_INLINE) { + $node->teaser = _node_read_more_link($node); + } unset($node->body); } else { @@ -1067,6 +1084,52 @@ function node_view($node, $teaser = FALS } /** + * Place the 'Read more' link on a suitable position in the teaser. + * + * @param $teaser + * The teaser in which the link has to be placed. + * @param $link + * The link pointing to the full node. + * + * @return + * The teaser with the link appended. + */ +function _node_read_more_link($node) { + $link = theme('node_read_more_link', $node); + $teaser = $node->teaser; + + // TODO: Need to look for any tag allowed by the current filter. + $marker = '
'; + + // Get last position of the marker. + $position = strripos($teaser, $marker); + + // Insert the link before the marker, if found, + // otherwise simply append link to teaser. + if (!($position === FALSE)) { + $teaser = substr_replace($teaser, $link, $position, 0); + } + else { + $teaser .= $link; + } + return $teaser; +} + +/** + * Theme the 'Read more' link. + * + * @ingroup themeable + */ +function theme_node_read_more_link($node) { + $text = str_replace(' ', ' ', t('Read more')); + $title = t('Read the rest of !title.', array('!title' => $node->title)); + + $link = l($text, 'node/' . $node->nid, array('html' => TRUE, 'attributes' => array('title' => $title))); + + return ' '.$link.''; +} + +/** * Apply filters and build the node's standard elements. */ function node_prepare($node, $teaser = FALSE) { @@ -1425,21 +1488,23 @@ function node_comment_mode($nid) { * Implementation of hook_link(). */ function node_link($type, $node = NULL, $teaser = FALSE) { - $links = array(); + if (variable_get('node_read_more_position', NODE_READ_MORE_INLINE) == NODE_READ_MORE_AS_LINK) { + $links = array(); - if ($type == 'node') { - if ($teaser == 1 && $node->teaser && !empty($node->readmore)) { - $links['node_read_more'] = array( - 'title' => t('Read more'), - 'href' => "node/$node->nid", - // The title attribute gets escaped when the links are processed, so - // there is no need to escape here. - 'attributes' => array('title' => t('Read the rest of !title.', array('!title' => $node->title))) - ); + if ($type == 'node') { + if ($teaser == 1 && $node->teaser && !empty($node->readmore)) { + $links['node_read_more'] = array( + 'title' => t('Read more'), + 'href' => "node/$node->nid", + // The title attribute gets escaped when the links are processed, so + // there is no need to escape here. + 'attributes' => array('title' => t('Read the rest of !title.', array('!title' => $node->title))) + ); + } } - } - return $links; + return $links; + } } function _node_revision_access($node, $op = 'view') {