#1 April 14, 2012 1:17pm

oliver
Member
Registered: April 6, 2012
Posts: 8

Advice on "public" modules

Any words of wisdom on creating a public module, such as a public image uploader, or simple comment system? I imagine some form of module driven callout that sanitizes user input. Darth Wordpress may be powerful, but the dark side of the cms will only consume me in hate and http requests of overwhelming magnitude.

Offline

#2 April 14, 2012 3:18pm

Farnsworth
Member
Registered: March 30, 2012
Posts: 13

Re: Advice on "public" modules

I'd recommend having a look at the non-get functions in the BigTreeModule class and the utility functions in the BigTree class.
For example, in BigTreeModule checkout add() - which does three things. First, it checks for duplicate entries in the table associated with your module. Next it creates a new entry in your table with the given values. Finally, it caches the entry so it's viewable immediately through the admin.
In the BigTree class, functions like createThumbnail may be useful if you're making an image uploader.
Have a good weekend.

Offline

#3 April 18, 2012 9:00am

benplum
Administrator
Registered: March 30, 2012
Posts: 54

Re: Advice on "public" modules

A simple comment system can be achieved by setting up a "comments" module. Build out a form to take the user input, as well as a process file that sanitizes the user input and makes use of the module's add() method. Something like:

$commentsMod = new SiteComments;
$keys = array(
	"name",
	"email",
	"comment"
);
$vals = array(
	$name,
	$email,
	$comment
);
if ($commentsMod->add($keys, $vals)) {
	echo 'Yay!';
} else {
	echo 'Boo!';
}

This process could also be run from an ajax call to avoid a new page load, sort of an auto-updating comment system.

Offline

Board footer

Powered by FluxBB

The Discussion Forum is not available on displays of this size.