Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Not Solved [General] Variables
#1
Not Solved
I've been out of luck finding the variables for total amount of posts, total amount of threads, newest member, and amount of members. I've looked over the stats but I'm aware those variables will not work in the ordinary template I am using.

Any suggestions?
Plugin Count: I lost count.
Public Plugins are available here.
Official GitHub.
Please do not PM me for support unless asked to.
Reply
#2
Not Solved
$stats['numposts']      = number of posts
$stats['numthreads']   = number of threads
$stats['numusers']      = number of users
$stats['lastuid']           = newest member (uid)
$stats['lastusername'] = user name newest member

When you want to use this in e.g. a plugin script, you must add:

global $cache;
$stats = $cache->read('stats');
Regards, Ad Bakker (NL)
Reply
#3
Not Solved
(08-29-2015, 06:35 PM)Ad Bakker Wrote: $stats['numposts']      = number of posts
$stats['numthreads']   = number of threads
$stats['numusers']      = number of users
$stats['lastuid']           = newest member (uid)
$stats['lastusername'] = user name newest member

When you want to use this in e.g. a plugin script, you must add:

global $cache;
$stats = $cache->read('stats');

Just as I thought. Wrapped it in the {} so it can be placed inside the templates and nothing was shown. Literally, the result of adding it was nothing.
Plugin Count: I lost count.
Public Plugins are available here.
Official GitHub.
Please do not PM me for support unless asked to.
Reply
#4
Not Solved
{$stats['numposts']}
{$stats['numthreads']}
{$stats['newest_user']}
{$stats['numusers']}
Reply
#5
Not Solved
(08-29-2015, 06:47 PM)Wires Wrote: Just as I thought. Wrapped it in the {} so it can be placed inside the templates and nothing was shown. Literally, the result of adding it was nothing.

Generally the variables are only available in index.php, and hence in templates that are evaluated from there, when they are evaluated after the line:
$stats = $cache->read('stats');

is executed.
Regards, Ad Bakker (NL)
Reply
#6
Not Solved
(08-29-2015, 06:51 PM)Sazze Wrote: {$stats['numposts']}
{$stats['numthreads']}
{$stats['newest_user']}
{$stats['numusers']}

This doesn't seem to work in templates as I already said.
(08-29-2015, 06:51 PM)Ad Bakker Wrote:
(08-29-2015, 06:47 PM)Wires Wrote: Just as I thought. Wrapped it in the {} so it can be placed inside the templates and nothing was shown. Literally, the result of adding it was nothing.

Generally the variables are only available in index.php, and hence in templates that are evaluated from there, when they are evaluated after the line:
$stats = $cache->read('stats');

is executed.

I am trying to execute these variables within the portal templates.
Plugin Count: I lost count.
Public Plugins are available here.
Official GitHub.
Please do not PM me for support unless asked to.
Reply
#7
Not Solved
(08-29-2015, 07:17 PM)Wires Wrote: I am trying to execute these variables within the portal templates.

When the portal stats setting:

AdminCP -> Configuration (Settings) -> Portal Settings -> Show forum statistics

is set to "yes", the variables are evaluated. But then it depends when your templates are evaluated, this must be after line 195 of portal.php. When your templates are evaluated before that, you must make a core change or handle it with a plugin.

Which templates are we talking about?
Regards, Ad Bakker (NL)
Reply
#8
Not Solved
(08-29-2015, 07:29 PM)Ad Bakker Wrote:
(08-29-2015, 07:17 PM)Wires Wrote: I am trying to execute these variables within the portal templates.

When the portal stats setting:

AdminCP -> Configuration (Settings) -> Portal Settings -> Show forum statistics

is set to "yes", the variables are evaluated. But then it depends when your templates are evaluated, this must be after line 195 of portal.php. When your templates are evaluated before that, you must make a core change or handle it with a plugin.

Which templates are we talking about?

The stats are displaying fine on the portal template. However, I'm trying to display the stats on the portal_latestthreads template.
Plugin Count: I lost count.
Public Plugins are available here.
Official GitHub.
Please do not PM me for support unless asked to.
Reply
#9
Not Solved
(08-29-2015, 07:58 PM)Wires Wrote: The stats are displaying fine on the portal template. However, I'm trying to display the stats on the portal_latestthreads template

Is this a plugin template? Then the plugin script that evaluates the template should contain the line (at the start):

global $stats;
Regards, Ad Bakker (NL)
Reply
#10
Not Solved
(08-29-2015, 08:35 PM)Ad Bakker Wrote:
(08-29-2015, 07:58 PM)Wires Wrote: The stats are displaying fine on the portal template. However, I'm trying to display the stats on the portal_latestthreads template

Is this a plugin template? Then the plugin script that evaluates the template should contain the line (at the start):

global $stats;

This is not a plugin. To make this easier I'm now trying to add {$stats} to the index template. The error is now "Array". Any idea? Seems like I can't place any variable on the front page of the forum, in a side bar by the way.
Plugin Count: I lost count.
Public Plugins are available here.
Official GitHub.
Please do not PM me for support unless asked to.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)