Community Documentation

v3 Knowledgebase

Unique Shoutbox for your custom Module

You can have a shoutbox block in your custom module with shouts that are only visible from that module. The capabilities are already in phpfox, you just need to know a few simple tricks to use them.

First, you need a new table in your database to hold the unique shouts. You can copy the phpfox_pages_shoutbox table to phpfox_yourmodule_shoutbox. Make sure that the first field is an autoincrementing key field. When I tried this, it lost this attribute on the new table and I had to edit that field and recreate it.

Then you must set a parameter. Somewhere in the controller where your shoutbox will be displayed you can enter this code:

$this->setParam('aCallbackShoutbox', array(
'module' => 'yourmodule',
'item' => 1

I just used 1 as the item. in pages, the item identifies the target page so that each page can have different shouts, but if you only need one in your module you can use 1 or 185 or whatever number you wish as long as you are consistent.

Then you need a callback service in your module. If you don't already have one, create the file callback.class.php within your modules service folder. Look at other service files to get the basic format, changing the class definitions to the proper values. (It should look like: class Yourmodule_Service_Callback extends Phpfox_Service) Within this file you need to place this function:

public function getShoutboxData()
return array(
'table' => 'yourmodule_shoutbox'

The entry is simply the name of the table that you created without the prefix.

Then create a block for your conroller from the admincp->CMS->add new block. You can use these settings:

Product: core
Module: Shoutbox
Title: {phrase var='shoutbox.shoutbox'}
Controller: url for your module's controller
Component: (shoutbox) -display
Placement: Block 3

I have shown Block 3 because it works in this location. It may also work in other blocks but I haven't tried them.

Always clear the cache after modifying your system.

If I have remembered everything, this should allow you to have a unique shoutbox for your custom module. I developed this on 3.4.1 and tried it out on 3.5.1.

No core changes should be required.