You should try to define the path with using Constants:
$button->set('link', JPATH_ROOT . '/plugins/editors-xtd/insertmystuff/insert_mystuff/mystuffplugin_dialog.php?e_name=' . $name);
$button->set('link', JPATH_SITE . '/plugins/editors-xtd/insertmystuff/insert_mystuff/mystuffplugin_dialog.php?e_name=' . $name);
You can also try with:
$button->set('link', JPATH_PLUGINS . '/editors-xtd/insertmystuff/insert_mystuff/mystuffplugin_dialog.php?e_name=' . $name);
you have to check if there is double slash or full url path is created then you just delete the slash before the path string ‘/‘ like this:
$button->set('link', JPATH_PLUGINS . 'editors-xtd/insertmystuff/insert_mystuff/mystuffplugin_dialog.php?e_name=' . $name);
Sometimes also works if you only just delete the slash from the beginning of the path and without a constant, do it like:
$button->set('link', 'plugins/editors-xtd/insertmystuff/insert_mystuff/mystuffplugin_dialog.php?e_name=' . $name);
And one more version which works if you are calling the path from admin, simply again with one slash:
$button->set('link', '/plugins/editors-xtd/insertmystuff/insert_mystuff/mystuffplugin_dialog.php?e_name=' . $name);
It always depends on where the path is called from. Since I cannot fully see your code that is why I gave many options to try. This is how we always call path nowadays. One of them should work.
UPDATE - ON JOOMLA 4 AND LINKS
I created different kind of link examples on my frontend in Joomla 4 to test what it gives back. So these are the links:
$link1 = '/editors-xtd/insertmystuff/insert_mystuff';
$link2 = JPATH_ROOT . '/editors-xtd/insertmystuff/insert_mystuff';
$link3 = JPATH_PLUGINS . '/editors-xtd/insertmystuff/insert_mystuff';
echo '<br>This is $link1: ' . $link1;
echo '<br>This is $link2: ' . $link2;
echo '<br>This is $link3: ' . $link3; die;
And this is what I got back on the frontend on cassiopeia template opening page:
This is $link1: /editors-xtd/insertmystuff/insert_mystuff
This is $link2: G:\websites\joomla4/editors-xtd/insertmystuff/insert_mystuff
This is $link3: G:\websites\joomla4\plugins/editors-xtd/insertmystuff/insert_mystuff
So, you can see what the different path values are given back to me on Joomla4 front-end (in localhost so it could be sometimes different on the web). There is no any problem with Joomla4 (alpha) link path creation. Thus we have to investigate and try the different path definitions a bit further on buttons.
UPDATE 2 - POSSIBLE WORKAROUND
I also do not see yet where this added path defined, actually it is adding a JPATH_ADMINISTRATOR constant to your given link always. It would take more time to check this why.
At the moment I see one sensible workaround of your problem and it is based on how other editors-xtd plugins are defining their links on their own buttons. It looks like that it's the more Joomla standard way. For example the CMS image button link:
$link = 'index.php?option=com_media&tmpl=component&e_name=' . $name . '&asset=' . $asset . '&author=' . $author;
or the pagebreak:
$link = 'index.php?option=com_content&view=article&layout=pagebreak&tmpl=component&e_name=' . $name;
Well, they just simply create it this way:
$button->link = $link; but it does not matter.
So this is what I see as a workable solution on this suddenly if you reformulate your link. If it could work for you:
for this link approach you should just move your plugin popup layout (dialog layout) file:
yourjoomla/administrator/components/com_content/tmpl/article folder and your button link should be rewritten to:
$link = 'index.php?option=com_content&view=article&layout=mystuffplugin_dialog&tmpl=component&e_name=' . $name;
And the button link set obviously:
Try this and we will see how it goes.
MORE APPROPRIATE SOLUTION
You do not have to! place your plugin layout file in the com_content folder directly, with that we just tried that the above path structure is working in your 10 years old plugin button object link. As I wrote in my comment, With the above path method, you can target and get your layout from other directories too. Most importantly there is a layouts folder in Joomla and in that folder at:
yourjoomla/layouts/joomla/content you can place your plugin modal layout file too and you should be able to call that with the above path structure method. Try that.
Nowadays we call layout files with the following method if for example my layout file is in my plugin folder and it's called for example
$mypathtoLayout = JPATH_ROOT . 'plugins/com_whatever/my_genius_plugin/layouts/'
$layout = new JLayoutFile('mylayout', $mypathtoLayout);
// and we just render and echo the $layout
So there are a lot of possibility of adding layout to anything in Joomla.
And just because of the “very smart kids” around here (they need at least 10-15 years more in this field), I also place the link to Joomla documentation about layout sharing in Joomla across extensions.
I also would like to highlight one sentence from this doc:
”Passing in a non-empty base path allows accessing and STORING layout files ANYWHERE on the site directory structure, for instance:...”
And another great Joomla doc about the layout system and how and when to use them and when not to:
And one more relevant thing about using JObject at all for buttons in plugins when you are now building an editor plugin for example, it is a BIG NO! Why? The notice about JObject getting deprecated started back in 2016 (at least). Making a button in layouts should be done with using Toolbar object (or new stdClass(); ), not JObject and not CMSObject! Link to this issue from 2016:
So giving an advice in 2018-19 on how to use a JObject in an editor plugin is just dumb as hell, as we all are usually. And we could continue this subject on and on but this question was just about a fast repair of a link on a button in an old editor plugin. So we can live with that. :)
JOOMLA BUTTON PLUGIN (EDITOR-XTD PLUGIN) - JOOMLA 4 - A NEVER-ENDING STORY
Now, of course I checked a bit more the Joomla 4 editor-xtd button plugin creation and I can confirm that it is just horrible. It's just a thing that Joomla core plugins use CMSObject (deprecated) and JObject (also deprecated) for these editor-xtd plugin creations, but on the top of that, if you just define a $link to your layout which is sitting in the site (not in the administrator part of your site) it is just impossible. Since the
$button->link in the button object and in Modal object is created the way that in any case the defined final
$link will be concatenated with 'Uri::base()'. You cannot avoid that. Here is how a button link is defined finally if you try to give a path to your layout:
$link = ($button->get('link')) ? Uri::base() . $button->get('link') : null;
And that is why @Rudolf has heavy headaches many days ago. He just wanted to refresh his plugin and tried to add his button to an editor with a "button plugin". Yes, sure, good luck for that :)
Changing the JObject to an anonymous PHP Object is easy and that way it won't be deprecated for a long time. It does not give any advantage in function but at least your plugin will not go break on JObject after a time. The
$button object only use a
get() function, nothing else, so if you just define a button this way, you cannot really go into trouble:
$button = new Class
public function get($property, $default = null)
// $link = 'index.php?option=com_content&view=article&layout=mylayout&tmpl=component&'
// . Session::getFormToken() . '=1&editor=' . $name;
$button->modal = true;
$button->class = 'btn btn-secondary mybutton';
// $button->link = $link; // this is the problematic part
$button->onclick = "mybuttonclick();";
$button->text = Text::_('MY BUTTON MINE');
$button->name = 'file-add';
$button->options = array(
'height' => '300px',
'width' => '800px',
'bodyHeight' => '70',
'modalWidth' => '80',
This is the very easy part. But if you define a
$link in the editor-xtd plugin, you can only go to the administrator directory for your Modal layout. So this is quite a shame for a button plugin in Joomla in 2019. It’s not a bug and it’s also true that it can be due to security reason just to not let people to call a button or a modal from external sources (as probably many have done that) and the site can be hacked via this button path. However, in this fashion, It only can work well, if someone really create a component (totally redundantly for a simple plugin), or create an ajax call to a Layout file and can call it that way from almost anywhere (at least we hope so).
ENDING THE LONG STORY
public function onDisplay($name)
// we have to add this short script here
$document = JFactory::getDocument();
alert("This script is running well");
let myurl = "/plugins/editors-xtd/editorextdmine/layouts/mylayout.php";
let dataframeval = \'<iframe class="iframe" src = "/plugins/editors-xtd/editorextdmine/layouts/mylayout.php" name = "MY BUTTON MINE" height = "300px" width = "800px" ></iframe >\'
"data-iframe": dataframeval ,
This short code actually changing two iframe attributes which is quite wrongfully generated by the Joomla Button Modal layout file and that caused this stupid problem. The button
#id and the
url value has to be changed to customized values and that is about it.
And the usual visual just to show that this script is working in Joomla 4 Modal loading in the editor with a custom button, loading the layout from the plugin's layouts folder: