Tina MVC for Wordpress

Tina MVC for Wordpress logoTina MVC
for Wordpress

Current version: 0.2.1 (released 2010-05-30)
Download locations: Wordpress Plugin Directory (preferred download location) or download tina-mvc.0.2.1 here.
Demo site: http://tina-mvc-demo.seeit.org/.

The GPL version of Tina MVC is currently supported on Wordpress.org. If you are interested in alternative licensing models, or in commercial support, please contact the author at http://www.seeit.org/about-us/.

What is it Tina MVC?

Tina MVC is a development framework for Wordpress that uses a loose model view controller (MVC) design pattern. (If you don’t know anything about MVC then don’t worry, just dive into the install and quick start tutorial). It is released to the community under the GPL v.2 license. It is a plugin that provides you with a base set of classes and helper functions upon which you build your Wordpress plugin, widgets and shortcodes.

Who is Tina for?

Coders, wannabe coders & people who are learning to code in PHP.

If you are going to do any database stuff, then you need to be familiar with MySQL and the Wordpress wpdb class. (As of yet there is no method for managing the creation and alteration of database tables when you activate and deactivate the plugin, but that feature is on the way.)

Without the code, Tina won’t do all that much, but if anyone wants to contribute some code, then please do and I will include it in the sample applications folder shipped with Tina.

Benefits:

  • separates your code from the core Tina MVC files – easy upgrades
  • non-intrusive, uses as few action hooks and filters as possible. For normal functionality Tina (v0.2.1) uses:
    • 2 page filters
    • 1 action hook for widgets
    • 1 shortcode hook
  • flexible enough for quick prototyping -  “Hello World!” in minutes with no M or V.
  • a forms helper class for generating forms and validating user submitted data.
  • an optional user dashboard, login, logout, registration, activation, password reminder screen that replaces the default Wordpress ones (still experimental).

Getting Started

Further Reference

2 Comments

  1. [...] verspricht bei dem Thema TinaMVC das nicht nur als Erweiterung für Plugins gedacht ist, sondern auch Standalone neben Wordpress [...]

  2. fcrossen says:

    Thanks to R’phael Spindel for taking the time to comment (moved from /about-us/):

    Just wanted to say I’m looking into Tina MVC.
    WordPress technically already *is* MVC architected (in a way), so this may be overkill, templates = view, WP_query = model WP_Rewrite = controller.

    Yes, it can be. However there are a myriad of action hooks and filters that you need to read up on. I wanted to be as non-invasive as possible and trapping a url call using WP_Rewrite was frankly something I didn’t consider. In the end I ended up trapping a call by hooking into the parse_query action hook and replacing (or generating) the post content and the post title.
    I’ll certainly look at WP_Rewrite again (well, for the first time!). When I first started with Tina, I found it difficult to get information on how to hook in my custom page properly, and I just dove straight in.
    Using Wordpress templates was ruled out for two reasons:
    – they are theme dependent (and I wanted to keep all a Tina applications files in one location)
    – they are parsed after browser output starts (which prevents the use of HTTP headers)
    However by using the “replace post content” approach the generated page content just uses whatever theme template file you want and retains all other functionality that Wordpress gives you.

    With custom post types with post meta and custom comment types with comment meta, profile and profile meta, almost any data can be abstracted into the standard wp table structure.

    Yes – I’ll certainly be looking at that. So far, I haven’t had a need to (either I wasn’t using a DB or couldn’t use the Wordpress DB for reasons of data sensitivity). The base model class is pretty much just a skeleton at the moment, so it would be pretty easy to use the custom data stores in Wordpress.

    I see a lot recreating the wheel here with your custom tina-mvc escape functions which are in core esc_attr() etc.. .

    Good point (and I can’t remember my rational at the time). The recursive escaping function is now using the WP esc_hmtl() function (in the 0.3 development branch).

    Have you checked out Rasmus’ no-framework MVC framework?

    Not until now – but it is an excellent piece and I would agree with most of it.
    Tina MVC was primarily written to replace a custom web framework that I’ve been using for a few years. While there are things I don’t like about Wordpress (for example, it is a memory hog) it “does what it says on the tin”, is well maintained, has plenty of third party support and removes the necessity to maintain code. The custom login/registration/etc mechanism is another good example of recreating the wheel, but again it was done to replicate some core behavior in the framework Tina is replacing.

    The form helper is good work though, I haven’t seen anything like that in WP core, or have I missed it?

    Thanks. I was quite surprised that there wasn’t something similar in the core. I hate coding forms!
    There may well be other ways of hooking into WP that I missed when I started, but this was a bit of a learning experience with me – it was my first proper dive into WP code. I’m currently reorganising Tina and adding a few bells/whistles in the 0.3 branch. Check it out if you have time.
    Thanks again for the feedback and for looking at Tina.
    If you can, let me know how you get on.

Leave a Reply