An example of using FCKeditor in smarty

Source: Internet
Author: User
Tags php template

FCKeditor is currently the best online editor on the Internet.
Smarty is a PHP template engine written using PHP. It provides the separation of logic and external content. In short, it aims to use PHPProgramWhen the programmer is separated from the artist, changing the logic content of the program does not affect the webpage design of the artist. If the artist re-modifies the page, the program logic is not affected, this is particularly important in projects with multiple partners.

Files that call FCKeditor in smarty:

  1. // FCKeditor in smarty
  2.  //Rossy.cn@gmail.com
  3.  //
  4.  
  5. Require_once("Conn. php");
  6.  Require_once("Class/smarty. Class. php");
  7.  
  8. $ Smarty=New Smarty();
  9.  $ Smarty->Template_dir="../Templates";
  10.  $ Smarty->Compile_dir="../Templates_c";
  11.  $ Smarty->Left_delimiter="<{";
  12.  $ Smarty->Right_delimiter="}>";
  13.  
  14. $ Editor=New FCKeditor("Content");
  15.  $ Editor->Basepath="../FCKeditor/";
  16.  $ Editor->Toolbarset="Basic";
  17.  $ Editor->Value="";
  18.  $ FCKeditor=$ Editor->Createhtml();
  19.  
  20. $ Smarty->Assign('Title',"Rosy is here waiting for you");
  21.  $ Smarty->Assign('FCKeditor',$ FCKeditor);
  22.  $ Smarty->Display('Template. TPL');

However, the FCKeditor cannot pass the value when editing the data, but generates a null editor. Therefore, you can only use the following method:

  1. // FCKeditor in smarty
  2.  //Rossy.cn@gmail.com
  3.  //
  4.  
  5. Require_once("Conn. php");
  6.  Require_once("Class/smarty. Class. php");
  7.  
  8. $ Smarty=New Smarty();
  9.  $ Smarty->Template_dir="../Templates";
  10.  $ Smarty->Compile_dir="../Templates_c";
  11.  $ Smarty->Left_delimiter="<{";
  12.  $ Smarty->Right_delimiter="}>";
  13.  
  14. $ Editor=New FCKeditor("Content");
  15.  $ Editor->Basepath="../FCKeditor/";
  16.  $ Editor->Toolbarset="Basic";
  17.  $ Editor->Value="Here is a example of smarty and FCKeditor";
  18.  
  19. $ Smarty->Assign('Title',"Rosy is here waiting for you");
  20.  $ Smartyl->Assign_by_ref("FCKeditor",$ Editor);
  21.  $ Smarty->Display('Template. TPL');

Template. TPL:

  1. <Htm>
  2. <Head>
  3. <Title>Example Of Smarty Use FCKeditor</Title>
  4. </Head>
  5.  
  6. <Body>
  7. <P>Example</P>
  8. <P>Title: <{$ Title}> </P>
  9. <P> </P>
  10. <P>Content: </P>
  11. <P> <{$ FCKeditor}> </P>
  12. </Body>
  13. </Html>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.