I am wondering how many people have really used the actually power and extensibility of the great Wordpress. The more time I spend with it reading the code I come to know Wordpress can be extended into a powerful cms. Trust me Wordpress is not just blogging software and it’s more than that.

I know Wordpress can be extended to any complex cms without changing a single line in the Wordpress core. The more I dig the Wordpress I feel really stupid for writing such poor code in Organizer plug-in. There are two ways by which you can extend your Wordpress namely plug-in and themes.

I have used so many so many open source cms. But I just love to write a plug-in for Wordpress for its simplicity and power. Long back I wrote in my blog that I want to bring smarty in Wordpress. One good thing with smarty is when you code a big project it is very easy to handle the templates for you.

PHP:
  1. <?php
  2. /*
  3. Plugin Name: PluginSmarty
  4. Plugin URI: http://imthi.com/#
  5. Description: This is simple plugin to use smarty for backend.
  6. Author: Imthiaz Rafiq
  7. Version: 1.0
  8. Author URI: http://imthi.com/
  9. */
  10.  
  11. class pluginSmarty{
  12. var $tp;
  13. function pluginSmarty(){
  14. add_action('admin_menu',array(&$this,"addPages"));
  15. }
  16. function initTemplates(){
  17. define('SMARTY_DIR', dirname(__FILE__).'/smarty/');
  18. require(SMARTY_DIR . 'Smarty.class.php');
  19. $this->tp = new Smarty;
  20. $this->tp->template_dir = dirname(__FILE__).'/templates/';
  21. $this->tp->compile_dir = dirname(__FILE__) .'/cache/';
  22. $this->tp->cache_dir = dirname(__FILE__) .'/cache/';
  23. }
  24. function addPages(){
  25. add_management_page("PlugiSmarty","Smarty Test",1,"pluginSmarty",array(&$this,"showPage"));
  26. }
  27. function showPage(){
  28. $this->initTemplates();
  29. $this->tp->display("pluginSmarty.tpl");
  30. }
  31. }
  32. $psmarty = new pluginSmarty();
  33. ?>

If you like to see the implentation please download this file. I have just made it work here please change according to your neeeds.

pluginSmarty.zip