Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Markdown support for CakePHP Views

branch: master

Merge pull request #5 from vaughany/master

Minor update to the Installation part of the README to fit with CakePHP 2.4.2
latest commit fc941e7d70
Stef van den Ham authored October 25, 2013
Octocat-spinner-32 Vendor normalizations November 09, 2012
Octocat-spinner-32 View fix March 01, 2013
Octocat-spinner-32 README.markdown Added missing ; October 24, 2013
README.markdown

CakePHP Markdown

The Markdown plugin provides your CakePHP views with the ability to use Markdown instead of HTML.

Purpose

Why use Markdown instead of HTML you ask? There's a few useful applications. For instance, at Mind the Code I always write my Blog posts in Markdown while in bed or on the road. WHen I'm happy with what I wrote I just create a new entry in my blog database with the markdown text, and the Markdown plugin and some CSS do the rest. No need to go through the whole post and add <br />'s and <h1>'s

Another useful option is using it within a CMS. Instead of having bloated HTML in your database through one of the thousand WYSIWYG editors you can have your content-editors just write Markdown, and have plain and not-so-bloated content in your DB.

Installation

  • Clone the files from the repos into app/Plugin/Markdown
  • Load the plugin by adding the following into app/Config/bootstrap.php:
    • CakePlugin::load('Markdown');
  • Include the Helper in the controllers you want to use it with, or in AppController.php:
    • public $helpers = array('Markdown.Markdown');

Using Markdown

The simplest way to test if everything is working is by passing some markdown to your view. You can use the following example:

In your controller, make a EOF variable containing something like:

Markdown allows you to write text in a easy-to-read and easy-to-write plain text format,
and Markdown will convert it to structurally valid XHTML (or HTML).

You can easily make text **bold** or *italic*  
Use [Some link](http://www.example.com/ "Example")  
Use [Another link][] like so  

And any other Markdown features, as shown on [Daring Fireball][]

  [Another link]: http://www.mindthecode.com/
  [Daring Fireball]: http://daringfireball.net/

And set this to a variable. For instance, $plain and assign it to the view:

$this->set(compact('plain'));

Then in your view, all you have to do is:

<?php echo Markdown($plain); ?>

And watch the magic :)

For a full list of Markdown, please visit DaringFireball.net

Something went wrong with that request. Please try again.