CodeIgniter Forums
auto_typography class error? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: auto_typography class error? (/showthread.php?tid=58868)



auto_typography class error? - El Forum - 07-29-2013

[eluser]epseix[/eluser]
Slightly confused as having read up on this class/library - it's exactly what I need to format large text pulled from my database - however, the line breaks do no generate the desired results when the text is pulled from a variable.

Code:
$variable = "This is a \n paragraph";
auto_typography($variable);

HTML source code:

Code:
<p>This is a \n paragraph</p>

Am I missing something?


auto_typography class error? - El Forum - 07-29-2013

[eluser]jairoh_[/eluser]
use <br> instead. html does not read \n


auto_typography class error? - El Forum - 07-29-2013

[eluser]ortwin.van.vessem[/eluser]
Ensure you have loaded the helper class in the autload.php or in the controller and use it like below in your controller.

Code:
$string = "Line 1 \nLine2";
$data['string'] = $this->typography->auto_typography($string);

$this->load->view('view', $data);

In the view you can use the variable $string.