Hey folks,
Currently working on an extra in which I want to use ExtJS or actually more specifically, ModExt (the countries dropdown) in my setup options form. I figure I would add a div to the script and then use that to house a panel with my various components, countries list included. Question is, how to include the script? I could of course inline the script but that could be messy maintenance-wise so I would prefer another option if possible. Another option would be to just hardcode the options in the select but I am sure there will be other times scripts would be useful - say for validation.
So is there a preferred way to include scripts? Views and opinions welcome.
-
☆ A M B ☆
- 3,141 Posts
I guess inline. As a package is installed the files are still in the core dir, so don't think there's a good way to include a script in a setup resolver.
Oh, and maintenance wise you should be able to script it in a different file and use file_get_contents() to get it into the resolver when you need it?
Hmmm, good point, hadn't considered that. Could host the file remotely though and reference that maybe...
-
☆ A M B ☆
- 3,141 Posts
Maybe, though you'd have to consider cross-domain requests (if any) in that case.
Yeah, won't be any in this case at least - will see if it actually works later - hate inlining scripts - specially in PHP.
Thinking more about this, I don't like the idea of calling the script remotely. I don't think folk will appreciate having external (untrusted) injections in their manager.
But, I have a cunning plan.
I'm going to make a blank package tomorrow and check the working directory that the resolver runs from by having it print it out - that should give me some idea of where to place the js file prior to installation via the validator script and where to call it from during the presentation of the setup options screen. Then I can remove it in the resolver when it has served its purpose.
Brilliant!
I think you could also include it as a file and remove that file in a second resolver.
---------------------------------------------------------------------------------------------------------------
PLEASE, PLEASE specify the version of MODX you are using . . . PLEASE!
MODX info for everyone:
http://bobsguides.com/modx.html
-
☆ A M B ☆
- 3,141 Posts
From what I know the resolver will be run by the manager/index.php file, but physically the package directory and its files will be in core/packages... can't count on that being available for including JS from on all setups.
Unless you'd somehow manage to first get the files copied over to core/components and assets/components and *then* get it, but I don't think you can
Quote from: markh at Mar 01, 2012, 07:51 PMFrom what I know the resolver will be run by the manager/index.php file, but physically the package directory and its files will be in core/packages... can't count on that being available for including JS from on all setups.
Unless you'd somehow manage to first get the files copied over to core/components and assets/components and *then* get it, but I don't think you can 
Perhaps creating a file in the cache directory and putting all data from the JS into that?

I can think of multiple ways to accomplish this...
@MarkGHErnst
Developer at Adwise Internetmarketing, the Netherlands.