Skip to:
Content

#2052 closed enhancement (fixed)

New Shortcode: Forum Statistics

Reported by: netweb Owned by:
Milestone: 2.3 Priority: normal
Severity: normal Version: 2.2
Component: 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 17 months ago.
2052.2.diff (5.2 KB) - added by MZAWeb 17 months ago.
2052.3.diff (8.7 KB) - added by MZAWeb 17 months ago.

Download all attachments as: .zip

Change History (11)

netweb17 months ago

comment:1 netweb17 months 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. :)

comment:2 MZAWeb17 months 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.

comment:3 follow-up: netweb17 months 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 17 months ago by netweb (previous) (diff)

comment:4 in reply to: ↑ 3 MZAWeb17 months 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.

MZAWeb17 months ago

comment:5 MZAWeb17 months 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.

MZAWeb17 months ago

comment:6 MZAWeb17 months ago

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

comment:7 johnjamesjacoby17 months 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.

comment:8 johnjamesjacoby17 months 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.