Method of calling FCKeditor in Smarty

  • 2021-07-24 10:18:34
  • OfStack

This article describes the example of Smarty call FCKeditor method, to share for your reference. The specific implementation method is as follows:

FCKeditor is currently the best online editor on the Internet.

smarty is a template PHP template engine written using PHP, It provides the separation of logic and external content, simply speaking, the purpose is to use PHP programmers and art separation, the use of programmers to change the logical content of the program will not affect the design of the art page, art re-modify the page will not affect the program logic, which is particularly important in multi-person cooperation projects.

The file that invokes FCKeditor in Smarty:

require_once("conn.php");  
require_once("class/Smarty.class.php"); 
 
$smarty = new Smarty(); 
$smarty->template_dir = "../templates"; 
$smarty->compile_dir  = "../templates_c"; 
$smarty->left_delimiter = "<{"; 
$smarty->right_delimiter = "}>"; 
 
$editor = new FCKeditor("Content") ; 
$editor->BasePath   = "../FCKeditor/"; 
$editor->ToolbarSet = "Basic"; 
$editor->Value      = ""; 
$FCKeditor = $editor->CreateHtml(); 
 
$smarty->assign('Title',"Rossy is here waiting for you"); 
$smarty->assign('FCKeditor',$FCKeditor);   
$smarty->display('template.tpl');

However, when editing data with this method, FCKeditor can't pass the value, but only generates an editor with null value, so only one method can be changed:

require_once("conn.php");  
require_once("class/Smarty.class.php"); 
  
$smarty = new Smarty(); 
$smarty->template_dir = "../templates"; 
$smarty->compile_dir  = "../templates_c"; 
$smarty->left_delimiter = "<{"; 
$smarty->right_delimiter = "}>"; 
 
$editor = new FCKeditor("Content") ; 
$editor->BasePath   = "../FCKeditor/"; 
$editor->ToolbarSet = "Basic"; 
$editor->Value      = "Here is a example of smarty and FCKeditor"; 
 
$smarty->assign('Title',"Rossy is here waiting for you"); 
$smartyl->assign_by_ref("FCKeditor",$editor); 
$smarty->display('template.tpl');

Template file template. tpl:

<htm>  
<head> 
<title>example of smarty use fckeditor</title> 
</head> 
 
<body> 
<P>Example</p> 
<p>title:<{$Title}></p> 
<p></p> 
<p>content:</p> 
<p><{$FCKeditor}></p> 
</body> 
</html>

I hope this article is helpful to everyone's PHP programming.


Related articles: