Site Summary Widget & Snippet

Site Summary Widget & Snippet

The following code can be used as an Inline PHP Widget For the MODX Dashboard or regular Snippet.

Posted on November 26, 2012 at 10:51:00
Tags: snippet, widget
Words: 195
Level: Advanced
Dependencies: None

<?php

$o = '<h2>Summary of Project Resources</h2>';
$o .= $modx->getCount('modResource', array('published' => '1')) . ' Published Resources: ';
$o .= $modx->getCount('modResource', array('published' => '0')) . ' Unpublished Resources: ';
$o .= $modx->getCount('modResource', array('deleted' => '1')) . ' Deleted Resources: ';
$o .= $modx->getCount('modResource') . ' Resources Total: ';
$o .= '<h2>Summary of Project Elements</h2>';
$o .= $modx->getCount('modChunk') . ' Chunks ';
$o .= $modx->getCount('modSnippet') . ' Snippets ';
$o .= $modx->getCount('modPlugin') . ' Plugins ';
$o .= $modx->getCount('modTemplate') . ' Templates ';
$o .= $modx->getCount('modTemplateVar') . ' Template Variables ';
return $o;

Example Output:

Summary of Project Resources

172 Published Resources:
46 Unpublished Resources:
3 Deleted Resources:
218 Resources Total:

Summary of Project Elements

96 Chunks
60 Snippets
7 Plugins
18 Templates
49 Template Variables

Comments

I intentionally violated the MODX Revolution separation of presentation code from PHP code rule, as Widgets are very basic implementations. Eventually, I would like to see Widgets take on a much larger scale rivaling that of User input, and custom Dashboard interfaces dedicated to user group and user roles.

MODX:
Website development platform combining security, power, and innovation.