dev-master
9999999-dev https://github.com/maurymmarques/markdown-cakephpA CakePHP plugin that facilitates the use of PHP Markdown with CakePHP
MIT
The Requires
- php >=5.3.0
- composer/installers *
by Maury M. Marques
plugin cakephp markdown
A CakePHP plugin that facilitates the use of PHP Markdown with CakePHP
This plugin facilitates the use of PHP Markdown with CakePHP, (*1)
PHP Markdown is a port to PHP of the Markdown program written by John Gruber., (*2)
“Markdown” is two things: a plain text markup syntax, and a software tool that converts the plain text markup to HTML for publishing on the web., (*3)
More info: http://michelf.com/projects/php-markdown, (*4)
For this plugin, the application Markdown is inside Vendor, (*5)
Written for CakePHP 2.x, (*6)
Copyright (c) 2011 Maury M. Marques, (*7)
You can install this plugin using Composer, GIT Submodule, GIT Clone or Manually, (*8)
[Using Composer], (*9)
Add the plugin to your project's composer.json
- something like this:, (*10)
{ "require": { "maurymmarques/markdown-plugin": "dev-master" }, "extra": { "installer-paths": { "app/Plugin/Markdown": ["maurymmarques/markdown-plugin"] } } }
Then just run composer install
, (*11)
Because this plugin has the type cakephp-plugin
set in it's own composer.json
, composer knows to install it inside your /Plugin
directory, rather than in the usual vendors file., (*12)
[GIT Submodule], (*13)
In your app directory (app/Plugin
) type:, (*14)
git submodule add git://github.com/maurymmarques/markdown-cakephp.git Plugin/Markdown git submodule init git submodule update
[GIT Clone], (*15)
In your plugin directory (app/Plugin
or plugins
) type:, (*16)
git clone https://github.com/maurymmarques/markdown-cakephp.git Markdown
[Manual], (*17)
Markdown
app/Plugin/
or plugins
Bootstrap the plugin in app/Config/bootstrap.php:, (*18)
CakePlugin::load(array('Markdown' => array('bootstrap' => true)));
Enable the helper using the plugin syntax, (*19)
If desired, set the component to assist with the return of data from the markdown., (*20)
// in app/Controller/BakeriesController.php class BakeriesController extends AppController { public $helpers = array('Markdown.Markdown'); public function index() { $this->set('textInMarkdownFormat', $yourTextInMarkdownFormat); } }
Or, if the markdown content is in a file..., (*21)
// in app/Controller/BakeriesController.php class BakeriesController extends AppController { public $helpers = array('Markdown.Markdown'); public $components = array('Markdown.Markdown'); public function index() { $this->set('textInMarkdownFormat', $this->Markdown->getFile($pathToMarkdownFile)); } }
In the view you can use something like:, (*22)
// in app/View/Bakeries/index.ctp echo $this->Markdown->transform($textInMarkdownFormat);
In the model you can use something like:, (*23)
```php // in app/Model/Bakery.php class BakeryModel extends AppModel {, (*24)
public $actsAs = array('Markdown.Markdown'); public function beforeSave($options = array()) { $this->data[$this->alias]['text_html'] = $this->transform( $this->data[$this->alias]['text_md'] ); return true; }
}, (*25)
A CakePHP plugin that facilitates the use of PHP Markdown with CakePHP
MIT
plugin cakephp markdown