IRC logs for #farmOS, 2022-09-24 (GMT)

2022-09-23
2022-09-25
TimeNickMessage
[20:00:03]<paul121[m]>hmm.. not sure I follow
[20:00:31]<paul121[m]>"the path to the library file" would end up in the <script src="path"</script> somehow?
[20:05:39]<paul121[m]><paul121[m]> "I imagine you have read this..." <- maybe their last resort helps with that :P
[20:05:40]<paul121[m]>> If using drupalSettings plus a JavaScript file is not an option, then you still have one option left: use hook_page_attachments(), where you add a new value to $page['#attached']['html_head'], which contains either a <script> tag or a <style> tag, as the “Inline JavaScript that affects the entire page” section above already showed.
[21:07:20]<paul121[m]>Welp, there doesn't seem to be a Drupal API for getting the library path. Which makes sense, because most library assets are aggregated and put into the public files directory. There's also complexity with libraries, TIL they can be provided at any of `web/libraries`, `web/profiles/libraries`, and `web/sites/{site name}/libraries` (!)
[21:07:20]<paul121[m]>But it seems you can get the path for any internal uri *relative to the base path* using: `Url::fromUri("base:/path/to/thing")->toString()`
[21:07:49]<paul121[m]>so in the end I have this working:... (full message at <https://libera.ems.host/_matrix/media/r0/download/libera.chat/7205ef6419...)
[21:11:31]<paul121[m]>just a matter of caching that final $resource_base_path maybe? That should be possible somewhere in the mix. I added that code to Element/FarmMap, and I believe that map render element should be cached. But maybe we could at a lower lever.. perhaps using Drupal state like mstenta mentioned?
[05:00:11]* scrdcow[m] has quit (Quit: You have been kicked for being idle)
[09:48:43]<skipper_is[m]>If I'm submitting a file through a form, is the way of adding the file to the log the same/simlar to adding an image? (1.x)
[09:48:43]<skipper_is[m]>I've got my file uploaded (well, generated, but it saves, I can download it), got the file ID, and tried to add it to the log through the entity_metadata_wrapper of the log `$log_wrapper->field_farm_files[] = array('fid' => $file_id);` Changed field_farm_images[] to files, as it's a csv. But it's throwing some PDO error, about `Column 'field_farm_files_display' cannot be null`
[09:49:02]<skipper_is[m]>Is field_farm_files_display the little description of the file?
[10:04:06]<mstenta[m]>Hmm i don't think i ever tried saving files directly from a quick form in 1.x
[10:05:39]<mstenta[m]>Oh it might need to be set to TRUE
[10:05:45]<mstenta[m]>?
[10:06:02]<mstenta[m]>I think display is a checkbox
[10:06:10]<mstenta[m]>Different from description
[10:06:32]<mstenta[m]>Surprising that it doesn't default to TRUE
[10:06:50]<skipper_is[m]>Ah, 1 also works, `$log_wrapper->field_farm_files[] = array('fid' => $file_id, 'display' => 1);`
[10:08:41]<mstenta[m]>Great!
[10:13:26]<skipper_is[m]>Variables on modules in drupal, can they be declared global? Outside of functions, are they global?
[10:14:54]<skipper_is[m]>Or is that bad drupal practice?
[10:15:12]<mstenta[m]>In D7 you can use variable_set() and _get()
[10:15:39]<mstenta[m]>Global PHP variables might work but bad practice
[10:16:44]<skipper_is[m]>Ah right
[10:56:14]<skipper_is[m]>ACTION uploaded an image: (755KiB) < https://libera.ems.host/_matrix/media/r0/download/matrix.org/PohPixVZwfd... >
[10:57:06]<skipper_is[m]>Fini! Aim of this little module is to generate a .csv for movements. This is uploaded to a government body in the UK called LIS (new ARAMS) when we're moving animals from one farm to another
[10:57:24]<skipper_is[m]>It will also log the movement in FarmOS and archive the asset if so desired
[11:01:34]<mstenta[m]>Wow that's awesome skipper_is!!
[11:05:54]<skipper_is[m]>It's rather rough around the edges, just tacked together enough to be functional!
[11:17:45]<skipper_is[m]>https://github.com/Skipper-is/farm_sendLIS If anyone UK based is still using 1.x, and might find it useful (warts and all)