Drupal 7 + Views 3, a dinosaur age problem: how to display Read More inline with the teaser text and not in the bottom with Comments links? I've already tried the following:
1. Overriding node.tpl.php like in this instruction: http://www.suburban-glory.com/blog?page=138
<div class="content"<?php print $content_attributes; ?>>
<?php
hide($content['links']);
hide($content['links']['#links']['node-readmore']);
print render($content);
if($teaser)
{
print l(t('Read more'), 'node/' . $nid, array('attributes' => array('class' => t('node-readmore-link'))));
}?></div>
<?php print render($content['links']); ?>
Didn't get me far because I had teaser text first, a Read More link under Teaser and Comments links yet under Read More.
2. Using Views module like in this instruction for Views 2: http://stonebergdesign.com/blog/moving-read-more-link-inline-teaser. Failed because in Views 3 I don't have Node:teaser field when using Fields in a view.
3. Searching for an existing module to do the job for me. Such thing exists but is in dev, not even in beta: http://drupal.org/project/read_more. I prefer not to use dev things - tons of bugs, ya know.
So if anyone is willing to put a newbie out of his misery, you're welcome.
Comments
=-=
in views add a field which allows you to link to the node. rewrite the field so that you can add "readmore" text
style with css to get it inline, or use the inline fields option in views.
only method I could come up with.
Eeerm. But this is exactly
Eeerm. But this is exactly where the problem is. :-) I don't see a way to do it. I need to show teasers with Read More link and I can do so with Views 3. My settings look like this:
Format
Format: Grid | Settings
Show: Content | Teaser
The problem is that the Fields region looks like this when I select Show Content:
Fields
The selected style or row format does not utilize fields.
I can change Format settings to display Fields instead of Content, but then it turns out I have all these Content:Nid, Content:Type, Content:Title and Content:Body but don't have Content:Teaser. So when I have teasers I don't have rewritable fields and when I have rewritable fields I don't have teasers. Or maybe I'm missing something and there actually IS a way to add a rewritable field to a teaser?
=-=
you would have to switch to fields instead of content
1)pull in the title field
2)pull in the body and set the 'Trim this field to a maximum length ' (to get teasers)
3)pull in another title field, rewrite the output, so that you can change the title into a readmore link
set 2 and 3 to be inline
Got some problems with this.
Got some problems with this. I added
Content:Title
Content:Body (trimmed to get a teaser)
Content:Link (a would-be read more. Needs no rewrite, btw, as it provides a link to full article by default)
Content:Add comment link
Content:Comment count
Then I went to Format -> Show -> Settings and marked Body and Link as Inline fields, but it didn't help. Stripping all fields of their default HTML didn't help either.
(Fixed this myself, never mind).
And another problem is that Add Comment link completely disappeared despite the fact I made sure to add it. It tells that it "displays the standard add comment link, which will only display if the viewing user has access to add a comment" - but I HAVE access to add a comment.So now I have something like this: http://ari-linn.nightmail.ru/fields_not_inline.gif. So I guess I've done something wrong.Try this way
You can get this feature by using views module.
Do this setting on view:
Format
Format: Unformatted list | Settings
Show: Fields | Settings
Fields
Content: Body
Content: Link
Filter criteria
Content: Published (Yes)
Content: Nid (= 1)
Outcome:
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.
read more
read_more
The module is called dev but the the maintainers, who wrote its D6 version, are just super-responsible. Reported bugs are minor. It is pretty safe to use. I use it.
Digit Professionals specialising in Drupal, WordPress & CiviCRM support for publishers in non-profit and related sectors
I'll try to use it then.
I'll try to use it then.
Btw is there any way to
Btw is there any way to override a module variable in Drupal? read_more.module has a variable in it:
define('READ_MORE_TEXT_DEFAULT', '<strong>Read more<span class="element-invisible"> about [node:title]</span></strong>');
That's not convenient for me because my site's content and interface is in Russian and I get something like "Япония начала модернизировать свою армию по европейскому образцу. Read more". I want "Read More" text to be in Russian. Is there any way to override module variable definition and keep this override in a separate file or should I modify read_more.module itself and be sure to restore needed values every time I get an update?
dunno
I don't know about that. My copy of Read More dev version has a config page with a box to enter the read more text you want to display.
Digit Professionals specialising in Drupal, WordPress & CiviCRM support for publishers in non-profit and related sectors
Hmmm, weird. Mine has only
Hmmm, weird. Mine has only help link and no config at all. I use 7.x-1.x of April 29, 2011 - 12:13.
no link from the modules UI but:
there is a link on the configuration page
admin/config/content/read_more
Digit Professionals specialising in Drupal, WordPress & CiviCRM support for publishers in non-profit and related sectors
Oh! Found it. Big thx. I
Oh! Found it. Big thx. I thought it adds a config link to Modules section, not to Config.
Smart Trim
Any one else with this problem? just use the Smart Trim module here http://drupal.org/project/smart_trim. I installed it and it works great, has everything you need.
Use Content: Path
You need to add the Content: Path field above your Content:body field, and exclude the Content: Path field from display.
Then, in your Content: body field, select Rewrite Results, and then Trim this field to a maximum length.
Next, set the More Link Text to "Read More"
Finally, under the More Link Path, add in [path] which is found under the Regular Expressions section.
Click save, and for any body content longer than the maximum length, there will be a read more link inline which links to your article.