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 11 Sep 2008 23:26:36 -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.974 diff -u -p -r1.974 node.module --- modules/node/node.module 6 Sep 2008 08:36:20 -0000 1.974 +++ modules/node/node.module 11 Sep 2008 23:26:38 -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; + var_export($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) { + $title = t('Read the rest of !title.', array('!title' => $node->title)); + + $link = l(t('Read more'), '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) { @@ -1428,7 +1491,7 @@ function node_link($type, $node = NULL, $links = array(); if ($type == 'node') { - if ($teaser == 1 && $node->teaser && !empty($node->readmore)) { + if ($teaser == 1 && $node->teaser && !empty($node->readmore) && variable_get('node_read_more_position', NODE_READ_MORE_INLINE) == NODE_READ_MORE_AS_LINK) { $links['node_read_more'] = array( 'title' => t('Read more'), 'href' => "node/$node->nid",