我已将 TinyMCE 安装到我的 codeigniter 构建中,并且包含了图像管理器。
在图像管理器插件中(保存在 public/assets 文件夹中)有一个 php 配置文件,它定义了图像和文件路径常量。
define('DIR_IMAGES', 'images/path/here'); etc
我遇到的问题是我需要根据数据库中的某些数据(例如 template_name)将路径动态化,但我不知道如何将正确的文件包含到配置文件中以便我可以查看动态信息。
所以如果用户保存了一个 template_name 那么我需要的路径是
define('DIR_IMAGES', $template_name.'images/path/here');
我还在 core/MY_Controller.php 中的一个常量中定义了 template_name,所以如果我可以访问该变量,这将比对数据库进行查询更容易,但无论哪种方式都可以。
谁能帮我解决这个问题,非常感谢!
最佳答案
我只是自定义了 tinymce 图像,但没有使用 TinyMCE 图像管理器。
但我使用下面链接中的教程。
How-to implement a custom file browser
<!-- Start tinymce custom -->
<script type="text/javascript">
tinyMCE.init({
<!--
your tiny mce init here
--->
<!-- custom file browser callback -->
file_browser_callback : 'myFileBrowser',
});
function myFileBrowser (field_name, url, type, win) {
// this is your dynamic image path
var cmsURL = "<?php echo base_url() ?>admin/media/select_image"; <== you can set as you wish
if (cmsURL.indexOf("?") < 0) {
//add the type as the only query parameter
cmsURL = cmsURL + "?type=" + type;
}
else {
//add the type as an additional query parameter
// (PHP session ID is now included if there is one at all)
cmsURL = cmsURL + "&type=" + type;
}
tinyMCE.activeEditor.windowManager.open({
file : cmsURL
,width : 600
,height : 600
,resizable : "yes"
,inline : "yes"
,close_previous : "yes"
,popup_css : true // Disable TinyMCE's default popup CSS
}, {
window : win,
input : field_name
});
return false;
}
</script>
关于php - Codeigniter:TinyMCE 图像管理器动态图像路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13547122/