BobRay / MyComponent

Development environment for creating MODX extras
https://bobsguides.com/mycomponent-tutorial.html
23 stars 13 forks source link

Static Elements on Install? #28

Closed pixelchutes closed 9 years ago

pixelchutes commented 9 years ago

When declaring elements as 'static' => true in the config, I can see this take effect on the instance with MyComponent installed. However, once you build and install on a vanilla instance, the static flag / path is lost.

Is there currently a way to declare elements as static as part of the transport package installation?

BobRay commented 9 years ago

No, I'm afraid not. The assumption was that while you might want static elements for development, you wouldn't want to force them on people using your extra.

pixelchutes commented 9 years ago

Makes sense. In this case, the extra would not be made public, and for each instance with it installed, the elements need to remain static.

Thanks again for all your efforts on MyComponent, Bob.

BobRay commented 9 years ago

Another problem is that the static_file path might be wrong. If you want to try it out, though, you could comment out lines 682 and 683 of \core\components\mycomponent\model\mycomponent\objectadapter.class.php

Let me know if it works.

pixelchutes commented 9 years ago

@BobRay

FYI, making just that change mostly worked. (A step in the right direction!) The snippets installed as static w/ a path, however the media source was not preserved (e.g. default / Filesystem)

I am also using a custom namespace path (with applied recommendations by you from #25) to install in non-standard core location. I'll need to ensure the "Static File Path" can be adjusted to mirror that before packaging and see if that gets preserved as well, otherwise the static file path after package installation ends up pointing to "assets/mycomponents/mySampleComponent/*", which does not exist.

BobRay commented 9 years ago

You may ultimately need to straighten out the static file path (and maybe the media source) in a resolver.

pixelchutes commented 9 years ago

I'll give that a shot!

UPDATE: FYI, I was able to get this to work using your suggestion. Ultimately, I resorted to manually updating the static paths in transport.snippets.php so the files could still be sourced local to my dev instance, but the final transport package is now installing as static, to the desired static_path. Thanks again!

UPDATE 2: I should also note that the default setup for installing as static did not set the Media Source. I know this is not designed to work that way, but documenting it here in case others attempt a similar approach and know to look for that.