CMarkdown with CGridView & CListView


How can I enable Markdown formatting for a specific column in GridView and ListView?


Any help on this would be greatly appreciated.

Hi itwy,

I hope this will do …

First, create a CMarkDown instance in the controller as a public property.

Then define the target column of the CGridView like this:


                'name' => 'foo',

                'type' => 'raw',

                'value' => '$this->grid->controller->markdown->transform($data->foo)',


In the code above, "$this" refer to the CDataColumn, and we access the CMarkDown instance through "grid" and "controller".

Please see the "value" property of CDataColumn in the reference for details.

Can you please provide me with that line, I’m getting an error.

Try adding the following in your controller that will use CMarkdown:

	private $_markdown = null;

	public function getMarkdown()


		if ( $this->_markdown === null)


			$this->_markdown = new CMarkdown();


		return $this->_markdown;