Forums / Code Collaboration / Encapsulated plugin, observer class loading javascript

Encapsulated plugin, observer class loading javascript

Views: 3,539

Results 1 to 3 of 3
8 Feb 2025, 11:06 AM
#1
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Location:
Gijón, Asturias, Spain
Posts:
2,876
Plugin Contributions:
7

Encapsulated plugin, observer class loading javascript

I'm working on making Structured Data as an encapsulated plugin.

Previously it was a jscript file that's autoloaded by the template head and gets most of its data from the various globals that are already in existence at that point.

When in the encapsulated plugin, it is included by an observer watching the end of the head.

In this scenario I find that the same jscript file does not have access to the same globals (e.g. $breadcrumbs): each one has to be declared as global prior to the include in the observer.

Any way to avoid or simplify that/an alternative method?

Steve
github.com/torvista: BackupMySQL, Structured Data, Multiple Copy-Move-Delete, Google reCaptcha, Image Checker, Spanish Language Pack and more...

8 Feb 2025, 12:00 PM
#2
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,119
Plugin Contributions:
56

Re: Encapsulated plugin, observer class loading javascript

The current version, IIRC, requires that the plugin's jscript file be copied to the active template's /jscript directory, doesn't it?

8 Feb 2025, 2:03 PM
#3
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Location:
Gijón, Asturias, Spain
Posts:
2,876
Plugin Contributions:
7

Re: Encapsulated plugin, observer class loading javascript

Correct.

Steve
github.com/torvista: BackupMySQL, Structured Data, Multiple Copy-Move-Delete, Google reCaptcha, Image Checker, Spanish Language Pack and more...