gpt4 book ai didi

乔姆拉! - 从按钮的 iframe 处理程序中的指定文件加载 editor-xtd 插件布局

转载 作者:行者123 更新时间:2023-12-02 03:15:39 25 4
gpt4 key购买 nike

我正在开发 Joomla! 2.5/3.x editor-xtd 按钮,我在单击按钮时从文件加载布局时遇到问题。

我尝试过这个方法:

$link = 'plugins/editors-xtd/myplugin/myplugin.layout.php?name='.$name;

$button = new JObject;
$button->modal = true;
$button->class = 'btn';
$button->link = $link;
$button->text = 'Insert something';
$button->name = 'myplugin';
$button->options = "{handler: 'iframe', size: {x: 500, y: 300}}";

...但是管理中生成的完整链接看起来像 http://my.local.host/mywebsite/administrator/plugins/editor-xtd/link-etc ..而且它不起作用。我也尝试过在 $link 中包含 JURI::base,但管理员路径仍然加载。

我是 Joomla 插件开发的新手!我进行了很多搜索,但没有找到解决方案。

** 我也尝试了这样的链接 index.php?folder=plugins.editors-xtd.myplugin&file=myplugin.layout.php&name=$name 但仍然没有。有没有针对此的练习,或者我必须创建并使用 JavaScript 函数来在按钮单击时运行?

最佳答案

解决方案

像这样修改链接变量(如果应用程序是管理员):

$link = '../plugins/editors-xtd/myplugin/myplugin.layout.php?name='.$name;

...和删除按钮选项(这意味着文件内容将通过模态中的ajax加载)

此外,在 myplugin.layout.php 中我们可以添加一些安全检查,并且我们可以导入 Joomla!框架库并定义,以便我们可以使用 Joomla!我们文件中的框架(例如语言加载之类的东西)这是我的实际文件头:

<?php

// No direct access
define('IS_AJAX', isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest');
if( ! IS_AJAX) die;

// Include J!Framework for later use
define( '_JEXEC', 1 );
define( 'JPATH_BASE', realpath(dirname(__FILE__).'/../../..'));
define( 'DS', DIRECTORY_SEPARATOR );
require_once ( JPATH_BASE.DS.'includes'.DS.'defines.php');
require_once ( JPATH_BASE.DS.'includes'.DS.'framework.php');

//more magic goes here...

关于乔姆拉! - 从按钮的 iframe 处理程序中的指定文件加载 editor-xtd 插件布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22644845/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com