WordPress.org

Ready to get started?Download WordPress

Forums

[closed] vexatious Read More links/lack thereof (8 posts)

  1. bcnbuda
    Member
    Posted 1 year ago #

    WP 3.5
    BuddyPress 1.6.2
    bbPress 2.3.2
    buddypress-sitewide-activity-widget

    In activity stream, posted Updates and replies to updates are excerpted and have [Read more] links. Clicking on the [Read more] link causes the update or reply to be expanded so the user can read the entire update. This works great and is intuitive, what users of sites like FB and many other blogs, etc expect.

    On the other hand, forum topics are excerpted but end with [...] which is not linked to the actual content and does nothing at all. The user has to know to click on the forum topic title in order to finish reading the content. This is inconsistent behavior and confusing to users.

    This seems to be a well known problem with no resolution. At minimum I would like to replace the [...] with something like [...Click Topic Title to Read more] but that is sub-optimal at best and I cannot find where the [...] comes from. Actually clicking the [...] and having it take you to the Topic would be better as an interim solution. I've tried numerous suggestions found here on this forum and elsewhere without any success.

  2. bcnbuda
    Member
    Posted 1 year ago #

    Oh, and here's a link to the page that demonstrates the problem - http://www.virtualstatesofamerica.com/activity/

  3. bcnbuda
    Member
    Posted 1 year ago #

    Found something interesting - My group forum topic excerpts in the activity stream that end with the cursed [...] and no Read More link are all right around 200 characters long, around 36 words. I found from much research that in /public_html/wp-content/plugins/buddypress/bp-activity/bp-activity-filters.php if I change the bp_activity_truncate_entry function at the following line from

    $excerpt_length = apply_filters( 'bp_activity_excerpt_length', 358 );

    to

    $excerpt_length = apply_filters( 'bp_activity_excerpt_length', 150 );

    then in my activity stream my group forum topic excerpts will now contain a …[Read more] link just like I want! It actually causes the excerpt to be expanded BUT it only expands as far as its previous length (about 200 characters or 36 words) before the above change and still ends with the [...] which is useless, a cruel mirage.

    So somewhere else the actual length of the excerpt that is being passed to the activity stream is being controlled and truncated to around 200 characters. If I could find where that is controlled I could lengthen it such that at least most of my excerpts could be expanded to their full length just like other updates (ie., non-group forum topics).

    Thoughts on where to look for this?

  4. bcnbuda
    Member
    Posted 1 year ago #

    Eureka!

    I think I've finally figured this out, a partial and reasonable solution anyway, and documenting it here for all the others who I have seen struggling with this problem for literally months or years in some cases. I'm sure there may be a more elegant way of handling it and perhaps someone can suggest a way that will survive upgrades and without editing core files (child theme changes?) but this "brute force" method works for the time being. This takes some explaining so hang in there with me.

    Part of the problem is that the behavior is handled in different files depending upon whether you're talking about updates (like What's new type of updates and their replies) or Group forum topics and their replies. The group forum topics end up in the activity stream with the dreaded [...] and do not expand which is a major bummer.

    After many hours of tril and error and research I have found that the size of the excerpt for group forum topics is controlled by
    /public_html/wp-content/plugins/buddypress/bp-core/bp-core-template.php beginning in the bp_create_excerpt function and the relevant parts that need to be changed are $length which has a default of 225 and array value for 'ending' which is "[...]" by default.

    In my case I made the length 3000 which is long enough for some pretty long topic posts and ending I made "Continues, click title" to give the user a hint that if the text is longer than 3000 characters and they want to read the rest they'll need to click the title of the topic in order to so. Still sub-optimal but a lot better than [...] which is inscrutable. A link to the topic would be better so it could just say continues and the user would click that

    function bp_create_excerpt( $text, $length = 3000, $options = array() ) {
    	// Backward compatibility. The third argument used to be a boolean $filter_shortcodes
    	$filter_shortcodes_default = is_bool( $options ) ? $options : true;
    
    	$defaults = array(
    		'ending'            => __( ' [Continues, click title]', 'buddypress' ),
    		'exact'             => false,
    		'html'              => true,
    		'filter_shortcodes' => $filter_shortcodes_default
    	);

    Now you also need to know that the length of the excerpt that is displayed in the activity stream in the first place whether an update, group forum topics, etc defaults to ~358 characters. That is controlled in /public_html/wp-content/plugins/buddypress/bp-activity/bp-activity-filters.php and possibly also in /public_html/wp-content/plugins/buddypress/bp-activity/bp-activity-template.php.

    Snippets from both:

    bp-activity-filters.php

    $excerpt_length = apply_filters( 'bp_activity_excerpt_length', 358 );

    bp-acivity-template.php

    $latest_update = apply_filters( 'bp_get_activity_latest_update_excerpt', trim( strip_tags( bp_create_excerpt( $update['content'], 358 ) ) ) );

    So by changing the 358 to a larger or smaller value you can change the "default" length of the "displayed" excerpt in the activity stream but the "actual" full excerpt (at least for group forum topics) is controlled by bp_create_excerpt in bp-core_template.php.

    Since the group forum topic "actual" excerpts default to 225 characters as explained above which is less than 358 that is why you see the [...] at the end of those excerpts by default. If you change the 358 above in bp-activity-filters.php to e.g.. 150, a value less than 225 then miraculously your group forum topics will have a "Read more" link but when you click the [Read more] link to expand the topic you will get at most 225 (150 + 75) characters and still the [...]! That's all you'll ever be able to get. Once you change the $length discussed above to 3000 (or whatever), that is greater than 358 and so you will get the "displayed" excerpt of ~358 characters and a Read more link but the "actual" full excerpt will be up to 3000 characters long and when the user clicks the Read more link it will expand to it's new maximum length of 3000, which in most cases will be the full text. More "breathing room" so to speak.

    Now, it appears that these "actual" excerpts must be created at the time the group forum topic is created and stored in the database for later retrieval and display. So you cannot expect to make these changes and see them reflected in your older posts. It appears this will only take place for your new posts going forward. At least that seems to have been my experience as a group forum topic I had just created still had the [...] and was only 225 and had the [...]. After I made the above changes to bp-core-template.php my post was still the same. So I copied the text of the post and deleted the group forum topic post and re-created it. Voila! My topic text now had a "displayed" length of ~358, a [Read more] link AND when I clicked it the post expanded to its full "actual" length which was less than 3000 characters!

    I'm not marking this as resolved because I'm hoping someone will come along and suggest a more elegant solution which will survive upgrades.

  5. Hugo
    Member
    Posted 1 year ago #

    @bcnbuda

    Rather than post this here or the four posts on bp.org linking back here, it would have been more helpful to open a ticket on BP's trac that way we would have seen it, the issue would be logged and a core developer could decide whether there was an issue to fix and examine/test your proposed change/fix.

  6. bcnbuda
    Member
    Posted 1 year ago #

    Hugo,

    valid point. I'm a newbie and just trying to be helpful. Still learning how to use this forum. This particular issue has been very frustrating for a lot of people. So I wanted those people to have the benefit of what I have learned not realizing it might cause a problem.

    I have posted several other technical questions on this forum that have so far gone unresponded to so it is not at all clear to me yet of what value this forum is. Perhaps I'm not formulating my questions correctly. I did have one problem that I posted in much the same way and got a very quick response and solution but since then nada. I was beginning to wonder if perhaps I was posting in the wrong place.

    It is interesting that for this particular issue my first and only response was over a procedural matter rather than a technical suggestion. I will try to do better and I will investigate using trac. I DO appreciate all the efforts of the developers and users of the community.

    Would you have any insights for me on the other questions I have posted about?

  7. bcnbuda
    Member
    Posted 1 year ago #

    updated Ticket #3715 - [Read more] doesn't appear for long group forum activity posts unlike regular activity updates

  8. Hugo is right and I seem to remember having made this suggestion previously.
    http://wordpress.org/support/topic/bbpress-vexatious-read-more-linkslack-thereof?replies=3

    If you could please continue this on the BB forum, that would be smashing.

Topic Closed

This topic has been closed to new replies.

About this Topic