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}
I’ve had the occasion of late to use social networking software on about a dozen sites. I’ve had to hack and tweak it to get it working just right, however, that is the true beauty of open source software: that it lends itself to easy modification by the end user. The software I’ve been using is called Boonex Dolphin. It contains all the bells and whistles for free, but quite a few features are adware and payware, which I don’t like but you can’t fault them for trying to pay the bills. The software is, after all, fairly complete. It offers modules for classified ads, dating, banner management, free and paid accounts, blogs, articles, video, music and photo sharing just to name a few.
Once installed, out of the box Dolphin provides a working site. It takes a while to get under the hood to figure out how it really works. I was first frustrated by it but then began to appreciate it more and more. However, the original programmers seem to get almost to the finish line in a lot of regards but then just stop short. For example, on one of the sites I worked on, New England Pet Guide, we needed to add a bunch of articles. I imported 2k articles and went to the admin article manager, and low and behold, the software tried to list ALL 2K ARTICLES in one screen. No paging at all. Now how can you build a modern software app without thinking ahead enough to include a pager (you know, so you can view 20 records at a time, browsing a large list). Anyway, that was among many of the fixes I had to make.
So while I was making these patches and mods it occurred to me, why not publish some of these patches mods and helpful tips here so (a) I can remember them
and (b) so others can benefit from them. In the next few days, weeks, I’ll be publishing my hacks and mods here for Boonex Dolphin, so stick around. Do you have any ideas for mods, hacks, or fixes for Dolphin?
web·pit n. a place of discovery; a repository of information; where coders come for enlightenment; a programmers diary.