2011-02-16 32 views
0

中更改TinyMCE external_image_list_url當用戶將圖像添加到文章中時,我使用圖像列表使他能夠在單獨的部分中添加圖像,並將它們添加到tinyMCE的文章中,但如果我們有大量的圖像用戶將找到一個長長的清單!它會不會很容易? 所以我希望找到一種方法來lmake每篇文章都有自己的圖像列表images_list.php?article_id = 333 ..如何在代碼

手風琴是所有文章標題的容器中,部分 時,點擊編輯或TinyMCE的添加AJAX做的工作 但如何改變每篇文章的external_image_list_url財產?????

+0

的例子? – Thariama 2011-02-16 12:42:37

+0

幾篇文章[一節中的所有文章]但只有兩個tinyMCE實例 – ahmedsafan86 2011-02-16 13:33:24

回答

0

當生成帶有php文件的javascript列表時,就像moxiecode中的這個示例一樣,您應該能夠根據文章獲取圖像。

玩得開心!

一個PHP生成圖像列表文件

<?php // this must be the very first line in your PHP file! 

// You can't simply echo everything right away because we need to set some headers first! 
$output = ''; // Here we buffer the JavaScript code we want to send to the browser. 
$delimiter = "n"; // for eye candy... code gets new lines 

$output .= 'var tinyMCEImageList = new Array('; 

$directory = "../../img"; // Use your correct (relative!) path here 

// Since TinyMCE3.x you need absolute image paths in the list... 
$abspath = preg_replace('~^/?(.*)/[^/]+$~', '/$1', $_SERVER['SCRIPT_NAME']); 

if (is_dir($directory)) { 
    $direc = opendir($directory); 

    while ($file = readdir($direc)) { 
     if (!preg_match('~^.~', $file)) { // no hidden files/directories here... 
      if (is_file("$directory/$file") && getimagesize("$directory/$file") != FALSE) { 
       // We got ourselves a file! Make an array entry: 
       $output .= $delimiter 
        . '["' 
        . utf8_encode($file) 
        . '", "' 
        . utf8_encode("$abspath/$directory/$file") 
        . '"],'; 
      } 
     } 
    } 

    $output = substr($output, 0, -1); // remove last comma from array item list (breaks some browsers) 
    $output .= $delimiter; 

    closedir($direc); 
} 

// Finish code: end of array definition. Now we have the JavaScript code ready! 
$output .= ');'; 

// Make output a real JavaScript file! 
header('Content-type: text/javascript'); // browser will now recognize the file as a valid JS file 

// prevent browser from caching 
header('pragma: no-cache'); 
header('expires: 0'); // i.e. contents have already expired 

// Now we can send data to the browser because all headers have been set! 
echo $output; 

?> 
在初始化TinyMCE的不用戶只處理一個文章或數