作者kpdream (省省力氣)
看板PHP
標題[請益] smarty如何崁入文章編輯器
時間Fri Jun 17 00:03:31 2011
之前以news_add.php做好畫面
其中要轉換成編輯器的部份是
<textarea id="editor1" name="editor1"></textarea>
<?php
include_once "ckeditor/ckeditor.php";
$CKEditor = new CKEditor();
$CKEditor->basePath = 'ckeditor/';
$CKEditor->replace("editor1");
?>
有成功導入'梅問題教學的[CKeditor網頁編輯器]'
但轉換成smarty的程式與版面分割寫法
勢必要把之前的畫面檔news_add.php 轉換成news_add.tpl檔放在[templates]
此時寫在原來畫面檔的
<?php
include_once "ckeditor/ckeditor.php";
$CKEditor = new CKEditor();
$CKEditor->basePath = 'ckeditor/';
$CKEditor->replace("editor1");
?>
必須拿掉放在smarty寫法的news_add.php檔中
<?php
include('../lib/main.php');
include_once "ckeditor/ckeditor.php";
$CKEditor = new CKEditor();
$CKEditor->basePath = 'ckeditor/';
$CKEditor->replace("editor1");
$tpl -> assign("editor1",$CKEditor);
$tpl -> display('news_add.tpl.htm');
?>
可是沒反應
是因為replace("editor1")替換失敗嗎
還是哪裡出問題呢??
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 61.219.77.19
※ 編輯: kpdream 來自: 61.219.77.19 (06/17 01:12)
1F:→ derekypp:試看把javascript 前後都加上{literal} ... {/literal} 06/17 01:58
2F:→ derekypp:因為javascirpt大刮號和smarty預設的{$var}衝到了~ 06/17 01:59
3F:→ tkdmaf:何不考慮用純js版本的ckeditor??? 06/17 07:48
4F:→ kpdream:試著加入之後~發現{literal}被雙引號包住了... 06/17 12:32
5F:→ kpdream:成功了~感謝樓上兩位大大的提示~^^ 06/17 19:53
6F:→ kpdream:我是用純js+{literal}完成崁入編輯器^^ 06/17 19:54