-
Notifications
You must be signed in to change notification settings - Fork 0
SPAW
Category:Library::External | Category:Library::WYSIWYG
SPAW is a very powerful and easy to use visual editor that I like to use in my applications.
I wanted to keep it flowing with the rest of my CI app by using the loader class to load it (instead of including it at strange places in my views), so I turned it into a custom library which can be loaded.
Download the spaw2.zip file and unzip its contents into your libraries directory within your CI app.
Move the spaw.php file within the spaw2 directory into the libraries directory.
Note: as of CodeIgniter_1.5.3 the loader class cannot recurse directory structures in the libraries directory, spaw.php needs to be directly inside it.
Then, inside your controller do something like this: [code]class Test extends Controller { function Test() { parent::Controller(); $config = array('name' => 'SpawTest', 'content' => 'This should be in textarea.'); $this->load->library('spaw', $config); } function index() { $this->load->view('test_view'); } }[/CODE]
Notice 'spaw' is the name of the spaw.php library file the instance of the editor is loaded from there; and $config is the parameter array for the editor.
The $config array, the 'name' key holds the value for the name of the SPAW instance, and the 'content' key holds the value for the textarea (the text that shows up by default before the user does any input).
Now, to actually load the editor into the browser window, I chose to call it in my view like so: [CODE]<html> <head> <title>Test for SPAW LIBRARY</title> </head> <body> <?=$this->spaw->show();?> </body> </html>[/CODE]
$this->spaw->show() is what does the magic.
There are many, many other configurable options (width, height, stylehseet to use, toolbar config, etc) and can be set with SPAW's default static methods. Just remember to replace [CODE]$spaw->[/CODE] with [CODE]$this->spaw[/CODE]
Spaw can manage multiple tabs. To get it to work in your CI application, you must add a line into your controller.
Here is what need to be in your controller for 2 tabs:
[code] // use $row->content_english for database polled content // add wysiwyg_path_images and wysiwyg_path_swf to your config file // to tell SPAW where to put your files.
$config = array('name' => 'link_content_english', 'content' => $content_english, 'caption' => 'English', 'wysiwyg_path_images' => $this->config->item('wysiwyg_path_images'), 'wysiwyg_path_swf' => $this->config->item('wysiwyg_path_swf'), 'default_width', '280px'); $this->load->library('spaw', $config); $this->spaw->addPage(new SpawEditorPage("link_content_french","link_content_french",$content_french);
// I learned from experience that you need to set the first 2 parameters // to identical values for the editor to work multi tabs...
[/CODE]
This integration is not exhaustive and I am releasing this under the same license the software came with.
Sudoku resources auto insurance quotes cheap auto insurance quotes Web design company Freestyle Medela Resell Ebooks Forum thread SPAW documentation (needed!)