Jump to content


  • Posts

  • Joined

  • Last visited

  • Days Won


elabx last won the day on February 16

elabx had the most liked content!

About elabx

  • Birthday 04/12/1988

Profile Information

  • Gender
  • Location
    Mexico City

Recent Profile Visitors

15,075 profile views

elabx's Achievements

Hero Member

Hero Member (6/6)




Community Answers

  1. @bernhard updated it! For anyone that might come across adding something else on the admin theme's markup, here's a recommendation from Ryan: $src = "https://unpkg.com/alpinejs@3.10.2/dist/cdn.min.js"; $this->wire()->adminTheme->addExtraMarkup('head', "<script src='$src' defer></script>");
  2. @kongondo Also managed to load AlpineJS like this: https://github.com/elabx/AlpineJS Although only works with the edited core version files mentioned above lol Then on the Inputfield on init(), I can do: $this->modules->AlpineJS This was copied from: https://github.com/somatonic/JqueryDataTables Only adding the composer dependency since that's how I want to manage it through the Inputfield actually using Alpine
  3. Thank you both for your answers! I tried to remove the hook like you suggested but the script still gets appended twice in the presence of two of the same field 😑. Also added the request here: https://github.com/processwire/processwire-requests/issues/468 Also made the edit here: https://github.com/elabx/processwire/commit/9a261c18a232845d92abe8e411fa48a381563dfd I also dig your version @bernhard , like, if I want defer without value, this kinda looks weird? array( [ 'defer' => ''] )
  4. Just noticing I actually messed up that module with a commit I made but someone already sent a fix, let's hope it gets pushed.
  5. @LexSanchez So, I actually introduced a bug in the module with my last PR sorry about that 😞, @gmclelland seems to have pushed a fix for this in this PR, maybe also push the version? Thanks again!
  6. I use this fantastic module: https://processwire.com/modules/video-or-social-post-embed/
  7. @kongondo just out of curiosity, do you know what it would take if we wanted to share the same AlpineJS source for our modules? Have a ModuleJS derived AlpineJS module?
  8. 1000% something like this would be really nice! Do you keep track of where you have injected it somehow? I has previously solved loading it with the following hook on an Inputfield: $this->addHookAfter('AdminTheme::getExtraMarkup', function ($e) { $parts = $e->return; $parts['head'] .= "<script defer src='https://unpkg.com/alpinejs@3.10.2/dist/cdn.min.js'></script>"; $e->return = $parts; }); But then noticed Alpine got injected multiple times if I used the field in a repeater for example, within a page with the same field.
  9. Hi! I am adding Alpine.js to work with an Inputfield I'm building: public function renderReady(Inputfield $parent = null, $renderValueMode = false){ $this->config->scripts->add("https://unpkg.com/alpinejs@3.10.2/dist/cdn.min.js"); parent::renderReady($parent, $renderValueMode); } But seems to be that it requires the "defer" attribute to work correctly, otherwise I get a lot of errors from Alpine. From what I understand, the way the AdminThemeUikit loads the scripts is done here (wire/modules/AdminTheme/AdminThemeUikit/_head.php): // line 55 foreach($scripts as $file) { echo "\n\t<script type='text/javascript' src='$file'></script>"; } I also tried hooking into the AdminThemeUikit::renderFile to basically edit the output after finding the line where the alpine.js is loaded, but it happens multiple times if I setup different fields of the same type in the page (and maybe too hackish anyway??) Does anyone think it's worth making a pull request to make this more configurable? Maybe a hookable AdminThemeUikit:renderScriptTag($filename, $options) method in AdminTheme? I feel it makes sense to be able to add this attributes, since defer is now sort of standardized from what I read around the internet. foreach($scripts as $file) { $adminTheme->renderScriptTag($file); } I tried looking into initializing Alpine components any other way but had no success figuring out how to, yet 🙃 Thanks for further answers!
  10. Exactly this! Solved! Ohh!! This is neat 😮 Need to upgrade to latest RockMigrations, still on v1!
  11. Hi! @thetuningspoon this is a very old thread haha but wondering if you managed to figure this out? Maybe through a hook after page add?
  12. Seems to be getContext() is available until 3.0.162? https://processwire.com/api/ref/field/get-context/
  13. Just to elaborate on another possible method, since getOptions() returns a SelectableOptionArray inheriting from WireArray, you could also do: $columns = $options->slices(3); https://processwire.com/api/ref/wire-array/slices/
  14. Maybe something like this, but I'm not entirely sure it will work, place it on ready.php: $wire->addHookBefore('Inputfield::render', function($event){ // the field where the field to hide exists $page = $inputfield->hasPage; $inputfield = $event->object; if($inputfield->name != "field_to_hide_if_parent") return; if($page->id){ // maybe check for children of specific type? if($page->parent->template == "specific_type_of_page"){ // the condition on the parent page? if($page->parent->multiselect_field->name == "some-name"){ $inputfield->collapsed = Inputfield::collapsedHidden; } } } });
  • Create New...