Skip to:
Content

BuddyPress.org

Opened 8 years ago

Closed 8 years ago

#5029 closed defect (bug) (fixed)

display_comments=none does not work in activity loop

Reported by: pollyplummer Owned by: boonebgorges
Milestone: 1.9 Priority: low
Severity: minor Version: 1.7
Component: Activity Keywords:
Cc:

Description

When customizing the activity loop, there seems to be no change when using display_comments:

<?php if ( bp_has_activities( bp_ajax_querystring( 'activity' ).'&display_comments=none' ) ) : ?>

I would assume this would hide the threaded comments. display_comments=threaded works, as does display_comments=stream. The codex says that 'none' is the default, but it seems that 'threaded' is really what is shown by default.

Change History (7)

#1 @hnla
8 years ago

I have just run through bp_has_activities() for Sarah to see what was what.

Firstly Codex entry is now inaccurate stating two things:

  1. that the default value of $display_comments is 'none'.
  2. passing a string 'none' hides display of comments.

Function sets :

$defaults = array(

'display_comments' => 'threaded',

and requires bool false to hide display ' false for none, stream/threaded - show comments in the stream'

I checked and passing a string equiv to 'display_comments=0' works to hide as as far as I remember passing zero as a string or otherwise is technically bool false.

I'll add an update to the codex page to reflect this while leaving older entries in place but we may need to consider if passing string '0' is actually valid even if does seem to work - I'm not sure on that aspect.

#2 @boonebgorges
8 years ago

It looks like the codex has been wrong for a long time. The default value of the display_comments param has been threaded since r2485. The codex should be updated to reflect the fact that threaded is the correct default value.

FWIW, the default value of display_comments in bp_activity_get() is false. Maybe that's where the confusion originally came from.

I do see that there is some funny business with strict type checking and the display_comments parameter in BP_Activity_Activity::get(), which may make it impossible to actually turn off comments. I'm going to write a couple unit tests and report back.

#3 @hnla
8 years ago

@Boone I did update the codex as it could be a potential time waste and frustration for people.

Passing '0' does kill the comments , I originally thought because 0 as a string or int is essentially bool false but now not sure I'm not simply passing a value unrecognised so it's returning nothing.

I missed bp_activity_get() which is why I struggled to understand bp_has_activities() clearly which does become quite difficult to follow the flow of the passed params/args

Also I can definitely directly edit:

$template_args = array {
'display_comments' => false, //$display_comments,
)

and remove the comments from the activity display.

Last edited 8 years ago by hnla (previous) (diff)

#4 @boonebgorges
8 years ago

In 7127:

Adds tests for display_comments param of bp_has_activities() stack

Most of these tests currently fail, as it appears that there is no way to
exclude comments from the activity stream by using the querystring format

See #5029

#5 @boonebgorges
8 years ago

  • Milestone changed from Awaiting Review to 1.8
  • Priority changed from normal to low
  • Severity changed from normal to minor

hnla - Yes, I've found the same thing. It's possible to exclude comments like this:

if ( bp_has_activities( array(
    'display_comments' => false,
) ) )

But not using any querystring format, and not using the 'none' keyword, and not passing a 0.

At least some of these issue should be fixed at some point, but there are complications. I can't simply cast things to boolean, because of r3985, which I don't totally understand but would probably be broken by messing with the strict type check.

I've run out of time to look at this at the moment, so I'm going to move it to 1.8 and hopefully look at it in more detail in the upcoming days. Though, it's definitely not a regression, so it may get bumped.

#6 @boonebgorges
8 years ago

  • Milestone changed from 1.8 to 1.9

Let's settle this mess in 1.9.

#7 @boonebgorges
8 years ago

  • Owner set to boonebgorges
  • Resolution set to fixed
  • Status changed from new to closed

In 7574:

Support more liberal params for disabling comments in bp_has_activities()

The 'display_comments' argument of bp_has_activities() takes either a string
value (such as 'threaded') or a bool false to disable comments altogether.
However, the false check in the query method is strict, meaning that various
analogous null values for display_comments were not recognized. In particular,
the strict check made it impossible to disable activity comments via a
querystring, as is often done in templates: ?display_comments=0.

This changeset adds 0, '0', 'false', and 'none' to the possible values for
the null display_comments value, to support the longtime codex suggestions.
Changes are made at the level of bp_has_activities(), which means that the
query method still requires a string false for $display_comments.

Fixes #5029

Note: See TracTickets for help on using tickets.