[Extension] SForum


sql dump is in the module root folder, you could ofcourse use another type of database if you like,just create the necessary tables as shown in that file.

Attached is:

sforum.zip , the module itself

forum.zip , a demo app



Add attachments by drag&drop or multi file upload thanks to XUpload extension

Image attachments (with the extensions you approve) is shown in lightbox style(using easybox) 

A bbcode editor with preview functionality 

Edit the topic, or title  easily thrue ajax

Browse topics in a category and its latest threads etc

An ajax search function  that  searches in both title and content of all topics to get the results.

Neat slide-to-unlock(iphone/android style) captcha

Moderator functionality:

Move topic to a diffrent category (including trashbin category)

Delete topic

Make the topic sticky, or remove the sticky status


Comment with the bbcode editor

Quote comment

Edit comment

Upvote/downvote comment

Moderator functionality:

Delete comment


Browse topic per category

See latest treads and by who 

Quick browse between the other categories while viewing  one.

Moderator functionality:

Create, delete or rename categories in the admin panel

Decide the order in which the categories will be shown thrue a drag&drop sortable list in the admin panel

Other admin functionality:

View stats (currently only number of threads,comments and users) in a nice user friendly graph.

View trashbin, threads that instead of beeing deleted has been sent to the trashbin category so another moderator later on can study it and decide to delete it entirely or "approve" it, sending it back to a normal category that visitors and normal users can see.

To install:

Put the sforum folder in your protected/modules folder

in your config file make sure you have these things set:

'aliases' => array(

'xupload' => 'application.modules.sforum.components.xupload', //used for the attachment uploads





		'newTopicStatus'=>'visible', // or hidden. Description: What status should newly created topics get.

		'userClass'=>'User', //set the name of your user model

		'commentsPerPage'=>3, //number of comments per page

		'uploadDir'=>'/uploads/',// where to upload attachments

		'userUrl'=> "/user/view/id/{{userid}}", //the url to the user profiles in your project

		'imageExt'=>"jpg,gif,png,jpeg",// what extensions for attachments should be treated as images and shown in a easybox window if clicked




Question: What is the userUrl options and how do I modify it?

Answer: You should set the userUrl to the url that your app uses to show a users profile. In that url you should use {{userid}} at the place in the url where you use the userid. Sforum will automaticly swap this with the userid that has created a topic or comment.

Not good enough? Well just customize the userUrl method in SForumModule.php

Question: Why this instead of myBB or other feature rich forums?

Answer: This module was written to provide a basic forum experience that can easily be integrated in any yii project.

If you want an ultimate forum solution for big communities this wont suit you, since I’m a single developer doing this as a hobby and do not have the possibility to create a forum with ALL features. But many sites only needs something simple, and this module can easily be used with any user system.

This is also my attempt to make a forum as user friendly as possible using ajax more then the big forum solutions I’ve seen.

Question: How do I controll which ones are moderators? and who is allowed to comment or create topics?

Answer: Please look at SForumModule.php and look at these methods:

//moderator/admin method

//if this method returns true then the user will be able to delete comments,topics and move topics

//you can change the logic of the method if you want

public static function moderator()




		return true;


		return false;



//comment method

//if this method returns true then the user will be able to comment and reply to comments

//you can change the logic of the method if you want

public static function allowComment()




		return true;


		return false;



//topic method

//if this method returns true then the user will be able to create new topics

//you can change the logic of the method if you want

public static function allowTopic()




		return true;


		return false;



With this you can customize exactly who will be able to moderate the forum and who is allowed to comment. Currently this module does not support not logged in users to comment, since a userid will be needed for each comment and topic.

Question: Do I have to use bootstrap?

Answer: No, I have on purpose not used the bootstrap extension or any bootstrap javascript. Bootstrap is only used and included for the css.

You can remove this and modify the views to use any css you want. None of the functionality depends on bootstrap.

Question: Why is there javascript code in the views?

Answer: I’ve done the most I possibly can to move all jQuery code to the external sforum.js file. But some code has to be in the view to work properly.

If you find a way to decrease the amount of javascript code in the views, please provide your solutions and I will update this module.

Question: Why have you mixed CHTml::tag and html?

Answer: Originally I did all html code the old school way. But then I regretted that choice and started to convert as much as possible to CHtml code.

I’m alittle bit lazy and have not finished all of this yet, feel free to help and contribute your changes.

Hi Sampa, thanks for your time

I´m having some problems to make it work:

  • tbl_user is not in sql dump, instead i´m using data/schema_mysql.sql (ok)

  • create an user:admin/pass:admin (ok)

  • login in as admin(ok)

  • Forum Admin > Categories > New Category : showing a modal with no content.

Ah yes, this is true. Because I imagined that if someone wants a forum they already have a user table, I did not want to do something that could conflict with the existing solution.

Could you provide some error message for new category? It works for me so I can’t help unless I know what errors you get, what does it say in firebug or console?

I am lucky to find your forum extension ,thanks

I am receiving the error of no index in the view of the topic :(

Can you explain further? Because that does not help me with what your problem is.


thx for this extension

it will help me !

i was search for this type of project. many many thx

i’ve made two small modifications for integrate in my Yii project :

1 - suppress the loading of bootstrap CSS in registerAssets() of SForumModule.php because Bootstrap was already used in my project…

2 - modify the createUrl code in the categories _view.php ligne 12 et 13 by

 <?= CHtml::link(CHtml::encode($data->name),

                array('category/view','id'=>$data->id,'name'=>$data->name)); ?>

to make it work

i’ll continu to test this !!

because the creation of a topic show me a empty modal.


could you give us your config/main.php pls?

specially the URL Manager config… thx[/s]

lol i should load the demo…


it’s seems that your application will run correctly when she is located in the WebROot folder…

any tips for make it work in a sub-folder root whitout force ajaxcallbacks to a static adress?


thx per advance

a noob user of your script ;)

Thx for Your work .

But plz Fix some Issues:


[*]Set Your Urls with Yii::app()->baseUrl

[*]dont name your tables tbl_comment rename it to tbl_sforum_comment or whatever

[*]and fix the urls in your js scripts you comp only works with vhosts and .htacces not very usefull for some newbies


Ths DrMabuse

Ok here some update Fix

add this to your views/forum.php

<?php $script = 'var baseUrl = "'.Yii::app()->baseUrl.'";alert(baseUrl)' ?>

<?php Yii::app()->clientScript->registerScript('sforum_baseUrl',$script,CClientScript::POS_HEAD) ?>

then change to your ajax functions

function changeVote(id,type){


        type: "POST",

        url: baseUrl+"/sforum/comment/changeVote",

finally installed (without the DocSnyder Fix because he don’t totally work for me)

my fix consist in a manual Fix … arrgg !!

and…here is some errors

1 - a category name with spaces cause a error on creating topic (empty form…)

2 - action ‘changeCategory’ for topic seems inactive (or not existing?)

3 - after delete topic still show the topic (u should redirect the page? or no?)

4 - change sticky still show no sticky (should refresh page? or no?)

hope help you for an update…

The empty modal appears to me too, when the category name has one or more spaces. Do you know how to fix it?


Jair Batista

hi, Exist this extension for Yii 2.0 advanced???