Tina MVC Install and Quick Start Tutorial
Where Next?
Install
The hard(ish) way
Download from the WordPress Plugin Directory (preferred download location) or from the Tina MVC page on SeeIT.org.
Unzip and activate as usual.
The easy way
Install straight from within WordPress.
Hello World in Minutes
Once Tina is active, the default installation gives you a `front end page controller`. This is simply a WordPress page called `Tina MVC for WordPress` with a post (page) name (or URL slug) `tina-mvc-for-wordpress`. It will catch any calls to the Tina front end page controller and pass them on to your page controller. Confused…? Don’t worry – read on:
Fire up your text editor and create a new PHP file. Our “Hello World” page controller looks like this:
<?php class hello_world_page extends tina_mvc_base_page_class { function __construct( $request ) { parent::__construct( $request ); $this->set_post_title( 'Happy ' . date('l') ); $this->set_post_content( 'Hello World!' ); } } ?>
Save the file as ‘hello_world_page.php’ and upload it to the `/wp-content/plugins/tina-mvc/app/` folder on your WordPress site.
Now for the fun…
1. Call it using the default front end controller
Navigate to /tina-mvc-for-wordpress/hello-world on your WordPress site. Tina will intercept the page call and replace the title and content of the post by whatever you want. In this case the post/page title will be ‘Happy
2. Use the Tina MVC Widget
Look for the ‘Tina MVC Widget’, drag it to the sidebar of your choice and enter the following settings:

- Default Widget Title: Whatever you want – it will be overridden in your page controller anyway
- Visible to all users: Checked. This disables any permissions checks.
Save, and navigate to your WordPress home page. You should see your ‘Hello World!’ widget in whatever sidebar you dropped it in.
3. Use the Tina MVC shortcode
In any post or page use the following shortcode:
[ tina_mvc controller='hello-world'] (make sure you lose the space between the opening brakcet ‘[‘ and ‘tina_mvc’.
Note, you don’t see the page title when you use the Tina shortcode (for obvious reasons).
4. Use the Tina MVC function tina_mvc_call_page_controller() from within a page template.
echo tina_mvc_call_page_controller(string $controller, [string $role_to_view = FALSE], [string $capability_to_view = FALSE], [string $custom_folder = '']);
If you don’t see the ‘Hello World’ message you will quite likely see a pretty ugly error message. As Tina’s intended use is in development, I didn’t do any fancy error handling.
Main Points
- Your page controller files go in the `tina-mvc/app/` folder.
- They are named the same as the controller name, with hyphens ‘-’ replaced by underscores ‘_’ and with ‘_page.php’ appended.
- The class is named the same as above (without the .php extension).
- They should extend the tina_mvc_base_page_class.
For example:
http://example.com/tina-mvc-for-wordpress/hello-world
is mapped on to
hello_world_page class
in the file
wp-content/plugins/tina-mvc/app/hello_world_page.php
Important Note
This way of using Tina MVC means that any code in the constructor is run before any permissions checks are carried out. While this is fine for simple use (where you are not worried about permissions) you are strongly encouraged to use the dispatcher method to controll programme flow. See the Tina MVC Dispatcher Method Tutorial for more information.
Where Next?
Look at the `sample_apps` folder and copy the contents to `app`. Everything there is documented and will demonstrate some more features of Tina, including how to use separate view files, and how to use the forms helper.
And please share your experiences and code!
Fran.