Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Feed owners on my site complain that their entire feed item gets placed on their site - so the viewers of their feed on my site have no reason to go to their site. That's a legit concern.
Is there anyway to reduce the length of what is shown on my site so there is just the first few lines and then the viewer is urged to visit the source to read the rest?
That way both sites get the traffic.
I know it's usually a setting on the blog itself where the owner can stipulate how long their feed is that goes OUT but not many bloggers are savvy enough to change their settings themselves. ;)
Comments
Comment #1
vannen CreditAttribution: vannen commentedAs far as I can see, a user scanning a site for the headlines would find the task much easier if the items were all of uniform length, so having an option to regulate the text length appears to be a good idea.
Perhaps the "cleanest" way of doing this is in the node template for feed items. That way, you keep the entire node text in the database, don't modify the module, but still trim down the feed item text.
however, this option requires inserting extra code into the node template, meaning that overhead could be an issue for a busy site with many feed items. Truncating the text before it's inserted into the database saves space and would make rendering the feed items quicker.
I've coded the beginning of a solution to this problem that lets an administrator set the length in characters of the displayed text be set, in the Simplefeed settings. The code below could be inserted into simplefeed.module:
At line 426:
At line 451 (note the replaced closing bracket at the top)
This creates the variable simplefeed_max_body_text_chars, which could be accessed from either the node template of a theme or in the simplefeed_item module.
In order to truncate the text in a node template (this works for a Zen sub-theme, it'll need to be tested for other themes) add the following code in the content div of node.tpl.php, then save it as node-feed_item.tpl.php in your theme/sub-theme directory:
In order to truncate the text before it gets inserted into the database, you would need to insert similar (not the same!) code at line 357 of simplefeed_item.module. The problem with the above code is that it strips tags out of the content in order to uniformly truncate the text so any truncated text will loose tagged content such as links and pictures.
I haven't taken ownership of this issue as the code needs testing on different systems and some improvement. I hope this gives people a start.
Comment #2
vannen CreditAttribution: vannen commentedJust to add that with the above code you would go to admin/settings/simplefeed and set the maximum characters there. The default is zero, which does not truncate the text. Anything above zero will set the maximum.
Comment #3
vannen CreditAttribution: vannen commentedSetting to "needs work".
Comment #4
Scott Reynolds CreditAttribution: Scott Reynolds commentedwhy then did they put the whole post in their feed.
This seems like a non-issue to me.
As mentioned, you can theme up the feed_item so that its smaller if needed.