我想将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