Add CSS/JS to backend theme from plugin

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Add CSS/JS to backend theme from plugin

iwolf
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 | Threaded
Open this post in threaded view
|

Re: Add CSS/JS to backend theme from plugin

adityasharma
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/themes.adoc
2.
https://github.com/apache/ofbiz-framework/blob/trunk/themes/docs/themes.adoc#extends-common-theme

Thanks and regards,
Aditya Sharma

On Tue, Feb 16, 2021 at 5:58 PM Ingo Wolfmayr <[hidden email]>
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 | Threaded
Open this post in threaded view
|

AW: Add CSS/JS to backend theme from plugin

iwolf
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 <[hidden email]>
Gesendet: Dienstag, 16. Februar 2021 16:04
An: [hidden email]
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/themes.adoc
2.
https://github.com/apache/ofbiz-framework/blob/trunk/themes/docs/themes.adoc#extends-common-theme

Thanks and regards,
Aditya Sharma

On Tue, Feb 16, 2021 at 5:58 PM Ingo Wolfmayr <[hidden email]>
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 | Threaded
Open this post in threaded view
|

Re: Add CSS/JS to backend theme from plugin

Michael Brohl-3
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 <[hidden email]>
> Gesendet: Dienstag, 16. Februar 2021 16:04
> An: [hidden email]
> 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/themes.adoc
> 2.
> https://github.com/apache/ofbiz-framework/blob/trunk/themes/docs/themes.adoc#extends-common-theme
>
> Thanks and regards,
> Aditya Sharma
>
> On Tue, Feb 16, 2021 at 5:58 PM Ingo Wolfmayr <[hidden email]>
> 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 | Threaded
Open this post in threaded view
|

AW: Add CSS/JS to backend theme from plugin

iwolf
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 <[hidden email]>
Gesendet: Dienstag, 16. Februar 2021 18:52
An: [hidden email]
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 <[hidden email]>
> Gesendet: Dienstag, 16. Februar 2021 16:04
> An: [hidden email]
> 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
> <[hidden email]>
> 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 | Threaded
Open this post in threaded view
|

Re: Add CSS/JS to backend theme from plugin

Michael Brohl-3
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 <[hidden email]>
> Gesendet: Dienstag, 16. Februar 2021 18:52
> An: [hidden email]
> 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 <[hidden email]>
>> Gesendet: Dienstag, 16. Februar 2021 16:04
>> An: [hidden email]
>> 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
>> <[hidden email]>
>> 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 | Threaded
Open this post in threaded view
|

AW: Add CSS/JS to backend theme from plugin

iwolf
:) That’s how I do it right now and it works - that’s fine.

Imagine I want to make the plugin availabe to the community. How will I do that? Upload the plugin + theme override? I made friends with the idea of using "portlets" for application dashboards. Defining them in one place and show them on different places/applications. Makes a few things easier to deliver custumizations to my customers. In my current case I need additional JS/CSS files required by some portlets.

Nevertheless I guess I have to use the theme override solutions right now.

Thanks for your time!!!

Best Regards,
Ingo

-----Ursprüngliche Nachricht-----
Von: Michael Brohl <[hidden email]>
Gesendet: Dienstag, 16. Februar 2021 20:11
An: [hidden email]
Betreff: Re: Add CSS/JS to backend theme from plugin

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 <[hidden email]>
> Gesendet: Dienstag, 16. Februar 2021 18:52
> An: [hidden email]
> 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 <[hidden email]>
>> Gesendet: Dienstag, 16. Februar 2021 16:04
>> An: [hidden email]
>> 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/them
>> e
>> s.adoc
>> 2.
>> https://github.com/apache/ofbiz-framework/blob/trunk/themes/docs/them
>> e
>> s.adoc#extends-common-theme
>>
>> Thanks and regards,
>> Aditya Sharma
>>
>> On Tue, Feb 16, 2021 at 5:58 PM Ingo Wolfmayr
>> <[hidden email]>
>> 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 | Threaded
Open this post in threaded view
|

Re: Add CSS/JS to backend theme from plugin

Michael Brohl-3
Hi Ingo,

I see. You want the theme to "visit" every plugin to pick up ressources
which are meant to enhance the theme, right?

Thats interesting but - to my knowledge - not implemented or possible to
achieve OOTB. Sounds like a feature worth thinking about though.

Regards,

Michael Brohl

ecomify GmbH - www.ecomify.de


Am 17.02.21 um 09:17 schrieb Ingo Wolfmayr:

> :) That’s how I do it right now and it works - that’s fine.
>
> Imagine I want to make the plugin availabe to the community. How will I do that? Upload the plugin + theme override? I made friends with the idea of using "portlets" for application dashboards. Defining them in one place and show them on different places/applications. Makes a few things easier to deliver custumizations to my customers. In my current case I need additional JS/CSS files required by some portlets.
>
> Nevertheless I guess I have to use the theme override solutions right now.
>
> Thanks for your time!!!
>
> Best Regards,
> Ingo
>
> -----Ursprüngliche Nachricht-----
> Von: Michael Brohl <[hidden email]>
> Gesendet: Dienstag, 16. Februar 2021 20:11
> An: [hidden email]
> Betreff: Re: Add CSS/JS to backend theme from plugin
>
> 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 <[hidden email]>
>> Gesendet: Dienstag, 16. Februar 2021 18:52
>> An: [hidden email]
>> 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 <[hidden email]>
>>> Gesendet: Dienstag, 16. Februar 2021 16:04
>>> An: [hidden email]
>>> 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/them
>>> e
>>> s.adoc
>>> 2.
>>> https://github.com/apache/ofbiz-framework/blob/trunk/themes/docs/them
>>> e
>>> s.adoc#extends-common-theme
>>>
>>> Thanks and regards,
>>> Aditya Sharma
>>>
>>> On Tue, Feb 16, 2021 at 5:58 PM Ingo Wolfmayr
>>> <[hidden email]>
>>> 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 | Threaded
Open this post in threaded view
|

AW: Add CSS/JS to backend theme from plugin

iwolf
Hi Michael,

yes. It is in my working queue. I will create a jira with a proposal when I am ready.

Best regards,
Ingo

 


-----Ursprüngliche Nachricht-----
Von: Michael Brohl <[hidden email]>
Gesendet: Donnerstag, 18. Februar 2021 23:56
An: [hidden email]
Betreff: Re: Add CSS/JS to backend theme from plugin

Hi Ingo,

I see. You want the theme to "visit" every plugin to pick up ressources which are meant to enhance the theme, right?

Thats interesting but - to my knowledge - not implemented or possible to achieve OOTB. Sounds like a feature worth thinking about though.

Regards,

Michael Brohl

ecomify GmbH - www.ecomify.de


Am 17.02.21 um 09:17 schrieb Ingo Wolfmayr:

> :) That’s how I do it right now and it works - that’s fine.
>
> Imagine I want to make the plugin availabe to the community. How will I do that? Upload the plugin + theme override? I made friends with the idea of using "portlets" for application dashboards. Defining them in one place and show them on different places/applications. Makes a few things easier to deliver custumizations to my customers. In my current case I need additional JS/CSS files required by some portlets.
>
> Nevertheless I guess I have to use the theme override solutions right now.
>
> Thanks for your time!!!
>
> Best Regards,
> Ingo
>
> -----Ursprüngliche Nachricht-----
> Von: Michael Brohl <[hidden email]>
> Gesendet: Dienstag, 16. Februar 2021 20:11
> An: [hidden email]
> Betreff: Re: Add CSS/JS to backend theme from plugin
>
> 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 <[hidden email]>
>> Gesendet: Dienstag, 16. Februar 2021 18:52
>> An: [hidden email]
>> 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 <[hidden email]>
>>> Gesendet: Dienstag, 16. Februar 2021 16:04
>>> An: [hidden email]
>>> 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/the
>>> m
>>> e
>>> s.adoc
>>> 2.
>>> https://github.com/apache/ofbiz-framework/blob/trunk/themes/docs/the
>>> m
>>> e
>>> s.adoc#extends-common-theme
>>>
>>> Thanks and regards,
>>> Aditya Sharma
>>>
>>> On Tue, Feb 16, 2021 at 5:58 PM Ingo Wolfmayr
>>> <[hidden email]>
>>> 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 | Threaded
Open this post in threaded view
|

Re: AW: Add CSS/JS to backend theme from plugin

Nicolas Malin-2
Hello,

What I understand, your can cover your requirement through the decorator
extended in your customized theme.

By feedback it's more easier to manage each specificity through a
dedicated theme that extend the common-theme (or other) instead inject
some cross-functional dependencies.

But I grant that, it's currently not easier because each framework
screen doesn't have a decorator that we can extend.

Nicolas

On 19/02/2021 09:32, Ingo Wolfmayr wrote:

> Hi Michael,
>
> yes. It is in my working queue. I will create a jira with a proposal when I am ready.
>
> Best regards,
> Ingo
>
>  
>
>
> -----Ursprüngliche Nachricht-----
> Von: Michael Brohl <[hidden email]>
> Gesendet: Donnerstag, 18. Februar 2021 23:56
> An: [hidden email]
> Betreff: Re: Add CSS/JS to backend theme from plugin
>
> Hi Ingo,
>
> I see. You want the theme to "visit" every plugin to pick up ressources which are meant to enhance the theme, right?
>
> Thats interesting but - to my knowledge - not implemented or possible to achieve OOTB. Sounds like a feature worth thinking about though.
>
> Regards,
>
> Michael Brohl
>
> ecomify GmbH - www.ecomify.de
>
>
> Am 17.02.21 um 09:17 schrieb Ingo Wolfmayr:
>> :) That’s how I do it right now and it works - that’s fine.
>>
>> Imagine I want to make the plugin availabe to the community. How will I do that? Upload the plugin + theme override? I made friends with the idea of using "portlets" for application dashboards. Defining them in one place and show them on different places/applications. Makes a few things easier to deliver custumizations to my customers. In my current case I need additional JS/CSS files required by some portlets.
>>
>> Nevertheless I guess I have to use the theme override solutions right now.
>>
>> Thanks for your time!!!
>>
>> Best Regards,
>> Ingo
>>
>> -----Ursprüngliche Nachricht-----
>> Von: Michael Brohl <[hidden email]>
>> Gesendet: Dienstag, 16. Februar 2021 20:11
>> An: [hidden email]
>> Betreff: Re: Add CSS/JS to backend theme from plugin
>>
>> 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 <[hidden email]>
>>> Gesendet: Dienstag, 16. Februar 2021 18:52
>>> An: [hidden email]
>>> 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 <[hidden email]>
>>>> Gesendet: Dienstag, 16. Februar 2021 16:04
>>>> An: [hidden email]
>>>> 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/the
>>>> m
>>>> e
>>>> s.adoc
>>>> 2.
>>>> https://github.com/apache/ofbiz-framework/blob/trunk/themes/docs/the
>>>> m
>>>> e
>>>> s.adoc#extends-common-theme
>>>>
>>>> Thanks and regards,
>>>> Aditya Sharma
>>>>
>>>> On Tue, Feb 16, 2021 at 5:58 PM Ingo Wolfmayr
>>>> <[hidden email]>
>>>> 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
>>>>>