Important!!!!!! A problem when creating your own addons - Forum | JoomShaper
Awaiting an answer SP Page Builder

Important!!!!!! A problem when creating your own addons

Asked by Dmitry Goncharov 4 years ago Last activity 1 year ago

A problem when creating your own addons. In the file site.php the render() function works, but getTemplate() does not work.
Both functions work if the addon is located in the components/com_sp page builder/addons folder. Only render() works in the plugin folder. At the same time, the text from the front part ceases to be edited, only in a pop-up window.
This problem can be seen and tested in the plugin
Demo https://github.com/zareen-fatema/custom-addon

6 replies

Dmitry Goncharov Asked this

Is there any information?

Toufiq Senior Staff

Hi there,

Thanks for contacting us. Sorry for the inconvenience. I need to share your query with our developer team. Allow me time please.

-Thanks

‏‏‎ ‎J‏‏‎‎e‏‎‏‏‎‎n‏‏‎‎s W.‏‏‎

@Toufiq and @Dmitry you can ignore my message, I only want to follow this conversation. Unfortunately there is no function to follow a thread without replying.

Toufiq Senior Staff

Please use the latest version of Page Builder and make sure that you have download the plugin from the blog post. Thanks

Alvaro

Hi, I'm reviving this thread to see if a solution can be found after 2 years to the problem that the getTemplate() method doesn't work for plugin addons.

I did some research and found that the method_exists function in the components\com_sppagebuilder\views\form\tmpl\edit.php file, line 333, can't find the getTemplate() method for plugin addons. This is because the classes don't exist because they haven't been preloaded like the component addons and templates are.

This leads us to review the components\com_sppagebuilder\parser\addon-parser.php file. In this file, the getAddons() method preloads the addon classes for both the component and the template, but it doesn't exist for the plugin. You can improve here. I also found a quick fix in thegetAddonPath() method: modify the plugins section, which is 109 to 112 lines, and change the following code:

if (isset($plugins[$addon_name]) && $plugins[$addon_name])
{
return $plugins[$addon_name];
}

to:

if (isset($plugins[$addon_name]) && $plugins[$addon_name])
{
$plg_addon_name = $plugins[$addon_name];
if (file_exists($plg_addon_name . '/site.php')) {
require_once $plg_addon_name . '/site.php';
}
return $plg_addon_name;
}

Please, I'd like to know if you're going to fix this. I've worked on several add-ons from a template. I created the plugin to centralize the addons, and I was surprised to find that the getTemplate() method doesn't work for addons that are in plugins. Again, I need to know if you're going to fix this or not.

Thank you.

Log in to reply.