But... your plugin is a component as well, right? Just reference it like I showed below.

Your plugin's ofbiz-component.xml starts with

  <ofbiz-component name="my-plugin" ... location="webapp/my-plugin" ...

Your Javascript is in

  plugins/my-plugin/webapp/my-plugin/vendors/myscript.js

You reference it as

  <property name="VT_FTR_JAVASCRIPT['add']" value="component://my-plugin/vendors/myscript.js" />

in your Theme.xml

All out of my mind but I think this should work. Did I miss something?

Regards,

Michael Brohl

ecomify GmbH - www.ecomify.de


Am 16.02.21 um 19:52 schrieb Ingo Wolfmayr:
Hi Michael,

that’s what I already did - and yes it works. I am looking for a way to add js/css files 
to the plugin and make it available in other application. Saying: "Common-theme here 
are some additional files"

Something like:
<VisualThemeResource visualThemeId="COMMON_THEME" resourceTypeEnumId="VT_HDR_JAVASCRIPT" 
sequenceId="12" resourceValue="/reporting/js/Chart.min.js"/>
     <VisualThemeResource visualThemeId="COMMON_THEME" resourceTypeEnumId="VT_STYLESHEET" 
sequenceId="10" resourceValue="/reporting/css/Chart.min.css"/>

I have a plugin that provides two files - one css and one js. I would have to 
create, role-out and maintain the additionial theme just for the purpose of 
providing two files.

Best regards,
Ingo

-----Ursprüngliche Nachricht-----
Von: Michael Brohl <michael.br...@ecomify.de>
Gesendet: Dienstag, 16. Februar 2021 18:52
An: user@ofbiz.apache.org
Betreff: Re: Add CSS/JS to backend theme from plugin

Hi Ingo,

I'm not sure if I understand correctly, but you should be able to assign 
ressources through a component reference.

Have you tried to use

<property name="VT_FTR_JAVASCRIPT['add']"
value="component://my-component/vendors/myspecialscript.js" />

<property name="VT_FTR_JAVASCRIPT['add']"
value="/my-theme/vendors/myscript.js" />

in your Theme.xml? This works OOTB with ftl files, should also work with 
JavaScript, no?

HTH,

Michael Brohl

ecomify GmbH - www.ecomify.de


Am 16.02.21 um 17:44 schrieb Ingo Wolfmayr:
Hi Aditya,

I already create my own theme by extending an existing one. It works but I feel 
quite uncomfortable by creating a new theme for the purpose of adding a single 
.js file to an existing theme. I was hoping there would be a better solution 
and handle those things via the plugin.

Thanks,
Ingo

-----Ursprüngliche Nachricht-----
Von: Aditya Sharma <adityasha...@apache.org>
Gesendet: Dienstag, 16. Februar 2021 16:04
An: user@ofbiz.apache.org
Betreff: Re: Add CSS/JS to backend theme from plugin

Hi Ingo,

You may refer to documentation in themes.adoc[1]. Though I am not sure
if this is the right solution, maybe you can create your own theme
extending the existing one[2]

HTH

1.
https://github.com/apache/ofbiz-framework/blob/trunk/themes/docs/theme
s.adoc
2.
https://github.com/apache/ofbiz-framework/blob/trunk/themes/docs/theme
s.adoc#extends-common-theme

Thanks and regards,
Aditya Sharma

On Tue, Feb 16, 2021 at 5:58 PM Ingo Wolfmayr
<ingo.wolfm...@wolfix.at>
wrote:

Hi everybody,

is it possible to add a javascript/css from an addon to an existing
backend theme.

Case: I have created a plugin that provides various reports via portlets.
Now I want to use the portlet logic to show those reports on
different places like accounting, catalog a.s.o. Therefore I want the
necessary JS/CSS files loaded for the whole theme - not for the plugin only.

Long time ago I would have added those scripts via
VisualThemeResource
:) If possible I do not want to touch the original theme and I want
to avoid creating a new plugin just for the purpose of providing those filed.

Every idea would be highly appreciated.

Best regards,
Ingo

Reply via email to