Things they don't teach you in school
My day to day (actually night to night, weekends, holidays, before work, after work, and too many hours to count) web surfing and contacts with folks on the internet frequently lead me to experimenting with some new software, or in this case, developing a mod or a patch to an existing application. PHP Fox is yet another example of a fine piece of social networking software with room for improvement. As a result of a contact I made on a forum some time ago, I was engaged in modifying this application to show some basic stats on the home page. At first glance it seemed daunting, and not a job I really wanted to tackle. But as I peeked under the hood of the admin interface, I found some shortcuts and I am going to post them here.
The basic features of this app include:
The basic home page for the system looks like so:
What the user wanted was to add a stats module displaying the count of profiles, forums, etc the system has acquired. The admin page already had a module that displayed the info but not the front end site. So I basically modified the existing code to perform both in the admin context and the front end context, and added a function call to the home page template. The results looked like so:
The module appears on the lower right side of the home page. To apply this page, only three files were changed:
new file: includes/modules/Admin/classes/PhpFox_ComponentTodayStats.class.php
[php]
/* ———————— start PhpFox_ComponentTodayStats.class.php ————-*/
<?php
App::loadClass(’BaseComponent’);
/** Component for displaying site warnings
*
* @author Alexey Gaponik
* @version $Id: PhpFox_ComponentTodayStats.class.php 819 2006-09-19 14:39:29Z gaponik $
* @package module.admin
*/
class PhpFox_Mod_Admin_ComponentTodayStats extends BaseComponent
{
/** Process
*/
function process()
{
$oSrvAdmin = $this->_oModule->getService(’Admin’);
/* @var $oSrvAdmin PhpFox_Mod_Admin_ServiceAdmin */
$oTpl = &$this->_oModule->getTemplate();
$oTpl->assign(array(
‘aStats’ => $oSrvAdmin->getTodayStats(),
‘aParams’=>$this->_aParams
));
return $oTpl->fetch(’TodayStats.html’);
}
}
?>
/*———————— end of PhpFox_ComponentTodayStats.class.php ————-*/
[/php]
Lastly, I Made changes to a template: design/templates/public/index.visitor.html
Towards the bottom of this file you will see a line “</td>{* END right column *}”
Just above the </td> we put this code:
<br />
<table style=”width:100%;” cellspacing=”0″ cellpadding=”0″>
<tr>
<td style=”width:2%;”>
<img src=”{$sStylePath}line5.gif” alt=”" style=”vertical-align:bottom;” />
</td>
<td style=”width:98%;font-size:8pt;vertical-align:middle;” class=”mainmenu3″>
<div style=”padding-left:10px;”>
<span style=”vertical-align:middle;”> <b>TODAYS STATS</b> </span>
</div>
</td>
</tr>
</table>
<br/>
<div style=”text-align:center;”>
{module module=’Admin’ component=’TodayStats’ notitle=’true’}
</div>
I had to modify the admin template a bit too:
design/templates/_modules/Admin/TodayStats.html
Essentially, I just put an if .. then around the table header so I could customize it and add some flare:
{if $aParams.notitle!=’true’}
<tr>
<td class=”row-header” colspan=”2″><span>TODAYS SITE STATS</span></td>
</tr>
{/if}
web·pit n. a place of discovery; a repository of information; where coders come for enlightenment; a programmers diary.
Please click here to login to post a comment.