It would be a nice feature to only show the "read more" link if the text has been trimmed.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Sam152 created an issue. See original summary.

Sam152’s picture

Status: Active » Needs review
FileSize
2 KB
Sam152’s picture

FileSize
2.64 KB

For my purpose (linking to comments), the read more link also doesn't include the fragment that entity_uri can return. Adding that to this patch.

HLopes’s picture

Can confirm, smart trim is stripping all link options, meaning stuff like:

query
fragment
absolute
alias
external
language
https
base_url
prefix
script
entity_type
entity

I would suggest adding something like $link_options = $uri['options'];

Chris Matthews’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll

The 3 year old patch in #3 to smart_trim.module does not apply to the latest smart_trim 7.x-1.x-dev and needs to be re-rolled.

Checking patch smart_trim.module...
error: while searching for:
        $uri = entity_uri($entity_type, $entity);
        // But wait! Don't add a more link if the field ends in <!--break-->
        if ($uri && $settings['more_link'] && strpos(strrev($output), strrev('<!--break-->')) !== 0) {
          $extension .= l(t('@more_text', array('@more_text' => $settings['more_text'])), $uri['path'], array('html' => TRUE, 'attributes' => array('class' => array('more-link'))));
        }

        $output_appended = preg_replace('#^(.*)(\s?)(</[^>]+>)$#Us', '$1' . $extension . '$3', $output);

        //check if the regex did anything. if not, append manually
        if ($output_appended == $output) $output_appended = $output . $extension;

        // If linking to content is selected the trimmed text will have tags
        // removed from the trimmed text. Need to find a more elegant way of

error: patch failed: smart_trim.module:126
error: smart_trim.module: patch does not apply