我想將tiny_mce的image_list_url更改爲php文件。包括PHP文件作爲JS
我將url更改爲image_list.php文件。它生成與js文件相同的確切輸出文本。
但即使在給出相同的輸出後,它也不會顯示圖像列表。
我想知道內容類型是否影響它?
我的JS文件內容:
// This list may be created by a server logic page PHP/ASP/ASPX/JSP in some backend system.
// There images will be displayed as a dropdown in all image dialogs if the "external_link_image_url"
// option is defined in TinyMCE init.
var tinyMCEImageList = new Array(
// Name, URL
["Logo 1", "media/logo.jpg"],
["Logo 2 Over", "media/logo_over.jpg"]
);
我的PHP代碼:
<?php
require('../../../system/config.php');
$strPath = APP_ROOT.DS.'sys_uploads/images/';
$objFileList = dir($strPath);
$arrFileList = array();
while (false !== ($entry = $objFileList->read())) {
if(is_file($strPath.$entry))
$arrFileList[] = array($entry, ABS_URL.'/sys_uploads/images/'.$entry);
}
$objFileList->close();
header('Content-type: application/x-javascript');
//header('Content-type: text');
?>
// This list may be created by a server logic page PHP/ASP/ASPX/JSP in some backend system.
// There images will be displayed as a dropdown in all image dialogs if the "external_link_image_url"
// option is defined in TinyMCE init.
var tinyMCEImageList = new Array(
// Name, URL
<?php
if(count($arrFileList)>0)
foreach($arrFileList as $dataRow):
?>
["<?php echo $dataRow[0];?>", "<?php echo $dataRow[1];?>"],
<?php endforeach; ?>
);
我的PHP輸出:
// This list may be created by a server logic page PHP/ASP/ASPX/JSP in some backend system.
// There images will be displayed as a dropdown in all image dialogs if the "external_link_image_url"
// option is defined in TinyMCE init.
alert('test working or not');
var tinyMCEImageList = new Array(
// Name, URL
["Logo 1", "media/logo.jpg"],
["Logo 2 Over", "media/logo_over.jpg"]
);
編輯:
按照建議,我甚至增加這也是一個彈出消息沒有出現。
解決方案:
逼債知道什麼是我的代碼錯誤,但找到很好的解決辦法,從鏈接提示:
http://tinymce.moxiecode.com/wiki.php/Configuration%3aexternal_image_list_url
你爲什麼要計算'$ arrFileList'的大小?只要它是一個數組,它就不是'foreach'所必需的。 – Htbaa 2011-04-05 08:10:52
我想跳過,如果它的空白... thnx的建議...它可以幫助我優化我的代碼 – KoolKabin 2011-04-05 08:13:32