Skip to:
Content

bbPress.org

Opened 8 years ago

Closed 8 years ago

#2052 closed enhancement (fixed)

New Shortcode: Forum Statistics

Reported by: netweb Owned by:
Milestone: 2.3 Priority: normal
Severity: normal Version: 2.2
Component: API - Shortcodes Keywords: has-patch needs-ui
Cc: wordpress@…

Description

Introduce new bbPress shortcode [bbp-statistics] for bbPress Forum Statistics

Utilizing existing page template /extras/page-forum-statistics.php

Attachments (3)

2052.diff (1.7 KB) - added by netweb 8 years ago.
2052.2.diff (5.2 KB) - added by MZAWeb 8 years ago.
2052.3.diff (8.7 KB) - added by MZAWeb 8 years ago.

Download all attachments as: .zip

Change History (11)

@netweb
8 years ago

#1 @netweb
8 years ago

The attached 2052.diff is as far as I can get :(

I am presuming 'something' else regarding the actual page template needs to be initialized 'somewhere' else, any clues on what else needs to be done would be welcomed and I'll happily have a go at it. :)

#2 @MZAWeb
8 years ago

  • Cc wordpress@… added

The get_template_part won't work here because if you check templates/default/extras/page-forum-statistics.php, that's a full template, with header, footer, and all.

Probably we should create a new function that returns the statistics and use that function both in the template and in the shortcode.

#3 follow-up: @netweb
8 years ago

Hmmmmm... WordPress templating sink or swim time ;)

eg. bbp-lost-pass shortcode calls form-user-lost-pass.php

The form-user-lost-pass.php also has get_header(); ?> <?php get_sidebar(); ?> <?php get_footer(); ?> and is basically the same code except for what is inside the <divs> yet this works fine.

Is this because page-forum-statistics.php is a 'page' template whereas form-user-lost-pass.php is a 'form' template?

EDIT: p.s. Thanks for the reply and info

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

#4 in reply to: ↑ 3 @MZAWeb
8 years ago

Replying to netweb:

eg. bbp-lost-pass shortcode calls form-user-lost-pass.php

The form-user-lost-pass.php also has get_header(); ?> <?php get_sidebar(); ?> <?php get_footer(); ?> and is basically the same code except for what is inside the <divs> yet this works fine.

uhmm nop. It's just a form. Click again in the file you posted :)

Is this because page-forum-statistics.php is a 'page' template whereas form-user-lost-pass.php is a 'form' template?

Yes. When you load that template inside the shortcode, basically you're doing an inception thing. And what's worst, that template calls the_content(), so you get an infinit loop, because the_content() loads that same shortcode again.

What we need to do IMHO is get the code from line 30 to line 92 of page-forums-statistics.php into a new template part, and then call this new template part both from page-forums-statistics.php and the shortcode.

@MZAWeb
8 years ago

#5 @MZAWeb
8 years ago

  • Keywords has-patch added

2052.2.diff implements the shortcode.

Doesn't look very good, probably it needs some better markup / styles, but that's far from my strong suit.

@MZAWeb
8 years ago

#6 @MZAWeb
8 years ago

2052.3.diff also implements the widget. Still looking ugly, though.

#7 @johnjamesjacoby
8 years ago

  • Keywords needs-ui added
  • Milestone changed from Awaiting Review to 2.3

That's a pretty good first pass. Moving to 2.3 for more iteration.

#8 @johnjamesjacoby
8 years ago

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

(In [4510]) Statistics:

  • Add widget and shortcode for forum statistics.
  • Props MZAWeb.
  • Fixes #2052.
Note: See TracTickets for help on using tickets.