Thanks for helping out a great deal... I went ahead and packaged my Extra; I could get me head around making creating resources and assets particular folders optional.
To recap, here are my initial questions
https://forums.modx.com/thread/86192/trying-to-use-mycomponents?page=5#dis-post-540805
donshakespeare Reply #49, 1 week, 3 days ago
Okay, I am back.
I have three mild questions that are stumping me immensely
#1. Is it possible to set default value of file/image TVs with user's assets' url (no MODX tag)? Something like MODX_ASSETS_URL translated server-side to proper url
[[++assets_url]] works okay in the frontend, but in the Manager, phpThumb will not parse MODX tags and thus throw a thousand errors each time. (ANSWERED BELOW)
#2. I have been trying to understand user input and default resolver and all, but no progress. I want to make a LITE version of my Extra. I don't want certain asset folders to be installed, and chunks and demo resources (ANSWER: ...PENDING)
PROBLEM: $modx->getOption('userInstallOption', $options)
only works in resolver files. But objects have already been created before resolver file fires
#3. Does MyComponent respect the new dependency thing I am hearing about? Main Extra won't install unless all subpackages have been installed. (ANSWER: NO)
Many thanks in advance.
For anyone else in need of understanding, always follow very closely BobRay's tutorial/instructions; he very often foresees and clears the caches of yours and my stupidity.
Answer to #1
MODX image TV has an annoying phpthumb script that insists on showing you a thumbnail of your image. This means, you have to get the url right, I mean relatively right, or else there will be a billion error reports in your log.
Say you are in
site.com/manager/....
Your image TV input field, to preview an image in your assets folder must have something like ....(absolutely no absolute URLs here watch out!)
assets/component/myExtra/images/bliss.jpg
If you wish your Extra to have
default_text in an image TV, you'll have to do this maneuver upon installation since it would be foolhardy to guess that the target user has not renamed his assets folder. How do you get the name of the target assets folder?
In your main config file:
C:\modxLocal\core\components\mycomponent\_build\config\myExtra.config.php
find and alter
/* ********************************************* */
/* (optional) Array of extra script resolver(s) to be run
* during install. Note that resolvers to connect plugins to events,
* property sets to elements, resources to templates, and TVs to
* templates will be created automatically -- *don't* list those here!
*
* 'default' creates a default resolver named after the package.
* (other resolvers may be created above for TVs and plugins).
* Suffix 'resolver.php' will be added automatically */
'resolvers' => array(
'default'
),
If for some reason you have this, look in example.config.php
'default' means, when you bootstrap/ Export Objects in MyComponent,
myExtra.resolver.php will be created in
C:\modxLocal\assets\mycomponents\myExtra\_build\resolvers\
Luckily, this file is untouched once created - so you can edit it however you want.
I even copied over all my edits from
resource.resolver.php to this file - I don't want anything lost each time I rerun MyComponent.
The code in this resolver file will run upon installation,
after your MODX objects shall have been created on the target's site
$tv = $modx->getObject('modTemplateVar', array('name' => 'myExtraImageTV'));
$tv->set('default_text', basename(MODX_ASSETS_URL).'/components/myExtra/images/bliss.jpg');
$tv->save();
Why is this insufficient?
MODX_ASSETS_URL.'/components/myExtra/images/bliss.jpg';
Well, it would give you an unwanted absolute url, and phpthumb cannot handle that
/modxRootFolder/assets/component/myExtra/images/bliss.jpg
So,
basename(MODX_ASSETS_URL) will fetch the last word in
MODX_ASSETS_URL which will give the name of the user's assets folder whatever it is.
'assets/components/myExtra/images/bliss.jpg';
Remember,
default_text, not
default_value -- very very mucho annoying mistake if you do make it.
At this time, you may supply chunks, resources etc with target-specific info.
This is me Trying and successfully using the awesome MyComponent.
PS.
When I use MyComponent my mind immediately asserts:
nawhhhh! this definitely has Intelligent Design behind it... I'd sooner believe I was the one who wrote this Extra (me being Mr Trial Error Chance) than believe that the world came from a can of soup.