2

Is it possible to have body trimmed to lets say 150 chars with read more link, and when you click read more, full body field opens in colorbox ?

1

If you have Colorbox installed, you can install Colorbox Node & Overlay which will let you create a colorbox node link with a colorbox-node class (e.g. <a class="colorbox-node" href="/my/node/path">My Node</a>).

In your theme's node preprocess function, you can add that class to the read more link:

/**
 * Implements hook_preprocess_node() in your theme's template.php
 */
function MYTHEME_preprocess_node(&$variables) {
  if ($variables['view_mode'] == 'teaser') {
    $variables['content']['links']['node']['#links']['node-readmore']['attributes']['class'] = 'colorbox-node';
  }
}

You'll need to adjust your theme's stylesheet rules to hide the non-body fields (and other styling as necessary), but it will work.

4
  • Thx Shawn, but its a bit to much for me. – Azz Kawa Apr 28 '16 at 16:57
  • I'm doubtful there's a turnkey solution for you. This solution requires 3 things: knowing how download/install 2 modules (one of which is built into D7 core), knowing how to modify your customize your theme's preprocess_node function in template.php (or creating a subtheme for that purpose), and alter your theme's stylesheet rules (i.e. editing style.css). Learn how to do those 3 tasks (they're fairly common) and revisit the solution later. – Shawn Conn Apr 28 '16 at 17:17
  • Would this work for all nodes created for particular content type automaticly after i do those modifications ? – Azz Kawa Apr 28 '16 at 17:44
  • This will work for any node displayed in teaser mode that has a read-more link at the end of it. – Shawn Conn Apr 28 '16 at 17:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.