Documentation

This section is slowly being filled up. Please be patient.

Who is it for?

Everyone who is able to deploy Wordpress should be able to get Wildflower up and running. However to fully enjoy and benefit from the features of this CMS, you should be competent in these areas (or willing to learn):

  • Code separation. Understand the difference between view and bussiness logic.
  • RESTful architecture.
  • Unit testing.
  • The heart of Wildflower is the CakePHP framework.

This means this system is not so much for a typical PHP hacker, but for an agile programmer that is willing to learn and adopt the best practices. We also want to have fun along the way, so the idea of the system is not to stand in your way.

Requirements

  • Apache web server with mod_rewrite
  • PHP 5.2+
  • MySQL 4.1+

Fresh installation

  1. Extract the archive. Place the wildflower directory inside your web servers documents folder.
  2. Create a new MySQL database (utf8_unicode_ci collation is strongly recommented) and into this new database import the SQL file app/config/sql/wildflower.sql.
  3. Edit the app/config/database.php file with your database connection details.
  4. You've got a working copy of this site. You can start working on your project by modifying the application inside the app directory. When a new release of Wildflower comes, you simply replace the cake, vendors and wildflower directories.
  5. Access the admin area at /admin. The initial login/password combination is admin/admin321.

Installing to an existing CakePHP application

  1. Extract the archive and place the wildflower/wildflower directory inside your application root.
  2. Just include the Wildflower bootstrap.php file located at /wildflower/config/bootstrap.php in your /app/config/bootstrap.php.
  3. Load the SQL dump file app/config/sql/wildflower.sql into your database.
  4. Set up some routes. Check the wildflower/config/routes.php file for the default WF routes.
  5. Your app_controller, app_model and app_helper files should extend WildflowerController, WildflowerModel and WildflowerHelper.
  6. Copy app/webroot/css/wfadmin from the archive to your app/webroot/css.

Basic principles

A modern website usually consist of "static" pages, news or blog sections, contact form, provides RSS feeds and a number of features, specific to the site's aim or goal. The idea of Wildflower is to provide this common functionality, with a polished and user friendly interface and enable the programmer to effectively code the remaining specific features of the site, fully exploiting the PHP rapid development framework--CakePHP.

Wildflower uses the additional MVC paths feature of the CakePHP framework. It sits in it's own directory inside the application root. This allows the user to create application specific controllers, models or views in her /app directory. By mirroring any view file from the wildflower/views folder inside app/views you can override the default Wildflower files. This is a great way to customize any aspect of the CMS, especially extending the admin interface with additional sections or customizing existing ones to the site's needs without touching the original Wildflower code.

A real world example of building a site with some custom functionality

Imagine you want to build a simple site with the following requirements:

  • Content managed "static" pages
  • Contact form
  • Home page with four boxes with different content and each content managed

The first two requirements you've got out of the box. For the third one we'll create a new section in the admin interface and build our own model/view/controller that will handle the custom functionality.

Step 1: Create a new database table

Let's create a very basic table to hold our data.

CREATE TABLE home_page_boxes (
  id int(11) unsigned NOT NULL auto_increment,
  content text,
  PRIMARY KEY  (id)
);

We'll be using 4 table rows to represent our boxes. Insert those right away:

INSERT INTO home_page_boxes (id, content) VALUES(1, 'Box 1 content.');
INSERT INTO home_page_boxes (id, content) VALUES(2, 'Box 2 content.');
INSERT INTO home_page_boxes (id, content) VALUES(3, 'Box 3 content.');
INSERT INTO home_page_boxes (id, content) VALUES(4, 'Box 4 content.');

Step 2: Create the MVC files

For this simple example we actually don't need to create any model file, since CakePHP supports dynamic models. So let's create our controller. We'll create a file in app/controllers/ called home_page_boxes_controller.php and put some code into it:

<?php
class HomePageBoxesController extends AppController {
    
    function beforeFilter() {
        parent::beforeFilter();
        $this->pageTitle = 'Home';
    }

    function admin_index() {
        $boxes = $this->HomePageBox->find('all', 'id IN (1, 2, 3, 4)');
        $this->set(compact('boxes'));
    }
    
    function admin_update() {
        foreach ($this->data['HomePageBox'] as $name => $content) {
            $id = explode('-', $name);
            $id = intval(array_pop($id));
            $data['HomePageBox'] = array('id' => $id, 'content' => $content);
            $this->HomePageBox->create($data);
            $this->HomePageBox->save(); 
        }
        $this->redirect(array('action' => 'index'));
    }
    
    function index() {
        $boxes = $this->HomePageBox->find('all', 'id IN (1, 2, 3, 4)');
        $this->set(compact('boxes'));
    }
    
}

This code handles populating the the homepage and the admin section with data and updating (saving) new content in the admin section. Let's create the view files. Create a new folder called home_page_boxes under app/views/ . Under this folder add admin_index.ctp and index.ctp files.

admin_index.ctp could look like this:

<h2>Homepage Boxes</h2>

<?php
    echo $form->create('HomePageBox', array('action' => 'update'));
    
    for ($i = 0; $i < 4; $i++) {
        echo 
        $form->input("content-{$boxes[$i]['HomePageBox']['id']}", 
            array('type' => 'textbox', 
                    'value' => $boxes[$i]['HomePageBox']['content'], 
                    'label' => 'Box ' . ($i + 1), 'between' => '<br />', 'class' => 'box-fck')),
        $form->submit('Save');
    }
    
    echo $form->end();
?>

This will create an admin page with four TinyMCE editors each handling one box. Let's take a look at the index.ctp file:

<?php foreach ($boxes as $box) { ?>

<div class="home-box">
    <?php echo $box['HomePageBox']['content'] ?>
</div>

<?php } ?>

This will display the four boxes and their content.

Now copy the /wildflower/views/layout/admin_default.ctp to /app/views/layouts/ . There you can modify the file and add a link to our new home page boxes admin screen to the admin main menu. I'll leave this step to you. Remember: Every Wildflower view file that you mirror inside your app/views will be used instead of the original.

Step 3: Routes

Finally we need to let Cake know that we want to display the HomePageBoxesController::index() action when browsing to your-site.com root. Modify the first two routes in app/config/routes.php like this:

Router::connect('/', array('controller' => 'home_page_boxes', 'action' => 'index'));
Router::connect('/app/webroot/', array('controller' => 'home_page_boxes', 'action' => 'index'));

Maybe you're wondering about the second route. On some server configurations Cake incorrectly detects the site root (/) as /app/webroot . This fixes it. If you don't experience this problem (the home page works fine without the second route) you can remove the route.

As you can see, Wildflower enables you to use all the CakePHP power together with the out of the box functionality.