Username Password        Sign up Lost password


Create the home page

written by bcoos on 16 June 2012

Now we have the controller created from previous chapter.

Edit the controller.php to look like this

<?php // bcoos 2.0 GPL àèíóú UTF-8
class whyController extends bcoosController {
	function index() {

The controller have the default action on module index, it only calls the view, created in previous chapter.

The next step is to register module on bcoos.

Execute this query on the bcoos database, change table prefix if necessary.

INSERT INTO `bcoos_modules` (`id` ,`directory` ,`slug` ,`title`) VALUES ('53', 'why', 'why', 'why');

After executing the query go to you must see this screen:

The text that appears is the text entered on view file index.php on the create module structure chapter you can change this text and refresh browser to see changes.

But we want that for when we go to to achieve this we must register the method on bcoos, only registered methods that are available for anonymous users are possible home pages.

To register a method we need to create a string to associate with this method, bcoos provides interface translation to multiple languages, bcoos uses UTF-8 encoding and you can translate interface to your language if you want.

Register string

Login with the user provided during installation.

Go to administration > system > register strings

Enter the string identifier why_home_page it must be of form
(lowercase letters, numbers and underscores) ex(string10_exemple) enter in default language the string of the english translation in our case home page.

You can enter translations for your language select the new language option and choose the two letter iso of your language if it's not present above.

Click on save and you will get the Saved define message.

If you entered a new language you will see a field to enter translation for that language in new string registration.

We can access anywhere in the code the string registered
 using the function t()  use t('string_identifier')  to get 
the string in the selected default bcoos language

Now we can use the new string identifier registered to associate it to the why/index method.

Register method

Go to administration > system > register methods

Scroll down the page and the last module is why, you will see in red an unregistered method.

Click on unregistered index to register it.

Choose method type content and enter the define previously registered why_home_page save and you will see the message Method updated, if you scroll down the page on why section you will see the method registered with translation and method name in parentheses.

When bcoos registers a new method by default is only available to administrators group, now we can go to manage groups and make this method available to registered users and anonymous users.

Give permissions to method to anonymous and registered users

Go to administration > system > groups

Click on registered group go to why section and tick index to make this method available to registered users, make the same on anonymous group.

Now the index method can be the default index page.

Go to administration > system > configuration

In the middle of page on home page select why and index

Go to and you must see the home page is now an action of why module.

Now we will change the text provided during create module structure chapter.

Change the view file of why module index.php to this code:

<?php // bcoos 2.0 GPL àèíóú UTF-8 

echo t('why_home_page');

We must use the t() function for all strings to provide the possibility to use our applications in different languages.

Next chapter - Create first question

Previous chapter - Create module structure

Table of contents - How to make a Question / Answer site

View all tags bcoos why tutorial Write a comment

Create module structure

written by bcoos on 16 June 2012

Now we have bcoos installed but the default page when we go to our domain is to show blog/index action. But we can change this.

Our home page must be why/index, but at this time we don't have the why module.

To change default action to why/index we have to make few steps the first one is create a new module structure to hold our application.

Let's go to create the structure of why module.

A module contains a full application

The minimal folder structure of a bcoos module is the following:


Create the module folder structure inside a why folder.

In case we are making a foo module it would be inside a foo folder.

Module folder structure

The controller folder has one unique controller per module.

The controller have methods each one gets data from models and send it to the choosen view

The models folder can have one or more models.

Models get data from database and send it to controller

The view/themes/bcoos folder has the views files.

A view is a representation of the model

The views/themes/bcoos/blocks has the blocks files.

A block is a view embedded in a layout

The views/themes/bcoos/layouts has the layouts files.

A layout is a group of one view and 0 or more blocks

The views/themes/bcoos/css has the css files specific to module.
The views/themes/bcoos/js has the javascript files specific to module.
The views/themes/bcoos/images has the image files specific to module.

The tests folder has the tests specific to this module.

Minimal files at module structure

The minimal files a module can have are:


The model isn't necessary but without a model our site will be static.
For convention we name the model with the same name of module.

Create these three files with this content:


<?php // bcoos 2.0 GPL àèíóú UTF-8

class whyController extends bcoosController {

controller class naming moduleController


<?php // bcoos 2.0 GPL àèíóú UTF-8

class whyModel extends bcoosModel {

model class naming modelNameModel


<?php // bcoos 2.0 GPL àèíóú UTF-8 ?>

This is where the home page will go. 

Next chapter - Create the home page
Previous chapter - Install bcoos

Table of contents - How to make a Question / Answer site


View all tags bcoos why tutorial Write a comment

Install bcoos

written by bcoos on 16 June 2012

Go to were httpdocs reside on your domain and download bcoos files.
cd /home/to/your/
svn export
Svn will download files to the directory on a folder named core

Move files of core folder to the same directory and list files on the directory.
mv core/* .
mv core/.htaccess .
ls -a

You must obtain a file list similar to this.
.   applications  core       icon.png  index.php  INSTALL.en.txt   removeInstallDirectory.php  version.php
..  config.php    .htaccess  includes  install    LICENSE-GPL.txt  update

Remove core folder
rm -fr core

Go to the in your browser, you must see a screen like this:

At the
/home/to/your/ chmod the following files:
chmod 0666 config.php
chmod 0777 includes/cache
chmod 0777 includes/cache/permissions
chmod 0777 includes/cache/pages
chmod 0777 includes/image/uploaded
chmod 0777 includes/image/uploaded/anonymous
Fill the form with database settings and the administrator account data.

Click save and point again your browser to you will see a screen asking to remove install folder.

Remove install folder:
rm -fr install

Click on the link with your url and it must show the screen of a fresh bcoos installation.

Login with the data of administrator account provided during setup.

Now bcoos is installed properly.

Next chapter - Create module structure

Table of contents - How to make a Question / Answer site

View all tags bcoos why tutorial Write a comment

bcoos Tutorial - How to make a Question / Answer site

written by bcoos on 16 June 2012


View all tags bcoos why tutorial Write a comment

Powered by bcoos 2.0 | 0.0156 seconds | 28 queries | SQL: 0.0023 seconds | 41 files: 310.38 KB | HTML: 30.31 KB