-
Posts
6,671 -
Joined
-
Last visited
-
Days Won
366
Everything posted by bernhard
-
Ok... I did some more testing and I think it's better not to use the functions api at all in module development. It's a level of lazyness that is not good IMHO and could lead to severe problems/drawbacks in the future (when using the module in a multi instance environment). Thank you @Soma for that veto! That statement was actually wrong! I get proper suggestions when I stick to proper syntax and don't use shortcuts. I think that is a good practise as it is more verbose to newcomers (I have always liked reading other's code and how easy to understand PW's api is) and also reflects the internal PW structure better than plain functioncalls (wordpress is calling...). So my (currently ? ) final version is: $this->config->scripts->add($this->config->urls($this) . 'scripts/createInvoiceButton.js');
-
[SOLVED] Best way to assign properties but each properties only once
bernhard replied to dotnetic's topic in General Support
Absolutely, I just meant that it should not be the first thing to think about. In other words: Just build your module and think about the name when it's finished ? -
Hm. Somehow it didn't feel right to do it that way. But it's totally fine of course ? I was just curious of the reason...
-
[SOLVED] Best way to assign properties but each properties only once
bernhard replied to dotnetic's topic in General Support
I think the name doesn't matter too much. What about TableUniqueRows? -
Thank you for the discussion, really appreciate it! What about this? urls($this); // using functions api $this->urls($this); // without functions api and multi-instance proof I guess this is about as short as it can get ? The initial example would get: // from this config()->scripts->add(config()->urls->siteModules . 'RockCRM/scripts/createInvoiceButton.js'); // to that config()->scripts->add(urls($this) . 'scripts/createInvoiceButton.js'); Thank you soma for that hint. That's a real drawback, even if I've never worked with multi-instance so far. But I think it would be the best to already take care of that in my daily work. Unfortunately I totally lose intellisense in my IDE if i use $this->urls() instead of urls() ? Does anybody know if I can do something about that? Then it would be perfect ?
-
Great, thanks! Now that I'm using the functions API all the time I'll also use inputGet('myvar', 'integer') more ? very short but also verbose enough imho ?
-
[SOLVED] Best way to assign properties but each properties only once
bernhard replied to dotnetic's topic in General Support
Very nice and for sure the best solution ?? maybe you want to take the extra step and pack it into a module so that reusing/updating/improving is easier for you and others? -
Crazy, thank you Adrian! How do you know that? I think maybe I can improve how to read the docs or code. I had a look both in the API docs and in the code directly but didn't find this option...
-
Updated the module to make sure the filepath exists. I also added an example in the readme how to set a background:
-
IP geolocation and redirect user to their language
bernhard replied to Marco Ro's topic in Multi-Language Support
you could set a users default language on registration / creation of the user by location of the ip address. if the user is not happy with that he can change it anytime. he will then see his favourite language on every login and you will save a lot of unnecessary ip/location lookups. -
great! thx soma! this is also possible and imho the cleanest solution: config()->scripts->add(config()->urls($this) . 'scripts/test.js'); thx ?
-
Hey! Something that has annoyed me several times already over time. I have this line in one of my modules: config()->scripts->add(config()->urls->siteModules . 'RockCRM/scripts/createInvoiceButton.js'); The line of code is placed in one module inside folder /site/modules/RockCRM, so what I tried first was config()->scripts->add(__DIR__ . '/scripts/createInvoiceButton.js'); But this throws an error that it is not allowed to add resources like this. I really want to get rid of the 'config()->urls->siteModules . 'RockCRM'' part! Is there any native function to add scripts via path (not via relative url)? Or is there a way to get the relative url of a module? I don't want to add the filename or module's name manually - hey, I'm already in that file, so that should really be easier, quicker and more future proof (thing of renaming the module one day...). I've built some helper functions in the past to do that, but they are spread wildly and implemented differently. I want to get one standard approach. I thought of submitting a PR to make the scripts take absolute paths as well, but I only want to do that if you guys don't know of an existing and good solution. Thanks for your help!
-
IP geolocation and redirect user to their language
bernhard replied to Marco Ro's topic in Multi-Language Support
what about your own topic that you started in may? -
Thx, that was the first module I found, but I thought it is only for selecting a file to be used as template. Didn't read carefully enough that this is just an OPTION. Thx! I'll try this module first ?
-
Looks like this is exactly what I need! The image part was only the icing on the cake and can wait ? Thank you!
-
I really like the code suggestions of inteliphense even though they are not perfect and I'm not sure if the extension is still maintained well (https://github.com/bmewburn/vscode-intelephense/issues/135) One thing I'd have / know is how to tell intelephense that one variable represents a special class, like here in my hook where the form is retrieved via $event->arguments(0) and so vscode does not know that is is an InputfieldForm class. Can I do something like this somehow? /* @var $form ProcessWire\InputfieldForm */ What I want to have is something like this: And what I get is this:
- 246 replies
-
- visual studio code
- vsc
-
(and 2 more)
Tagged with:
-
Hey @adrian thx again for the great panel settings shortcut. It already saved me from a lot of clicks ? For example today I added some todos in my code and activated the todo-panel. Then I had far too much todos indexed (from AOS and other modules) and I just clicked on the settings tab and added them to the list of not-to-index folders. Works great! One thing I noticed is that when I reload the page after adding a folder to the ignored-list the Todo-Panel was not activated any more. I activated it via the checkbox in the panel selector and clicked "sticky". After saving the module's settings this setting was gone. Is this a bug? Or can I activate this panel in another way? Thank you!
-
Is there a module to pick a file from a given directory? I want to pick a template for creating a PDF invoice and thought it would be nice to have the option to choose from different templates located in a folder somewhere in the sites folder. It's not hard to add a field to the edit form, but if there's already a ready solution for that I'd prefer that of course. I'd also combine it with a preview like I did on my first module: If nobody knows of an existing solution I'll go ahead and build one ?
-
nobody else having this problem? ?
-
Another snippet promoting the functions api ?
-
[SOLVED] Best way to assign properties but each properties only once
bernhard replied to dotnetic's topic in General Support
That's why I asked this question instantly: ? But I'm quite sure a custom script for the table field is the better solution anyhow ? -
absolutely awesome! thx! already using it ?
-
Thx @AndZyk for the Intelephense hint! Really awesome tool I was looking for for quite a long time ? Ever needed the correct collapsed state for one of your inputfields? No need to head over to the api docs any more ? and even with smart search (note that I typed "colloc")
- 246 replies
-
- 1
-
-
- visual studio code
- vsc
-
(and 2 more)
Tagged with:
-
Really great addition! Thank you! I wonder what others think of having the icon left instead of right. I think it'd be an improvement. Maybe if others think the same it would be worth the effort. If not, I'm also happy to have it on the right side now ? Thx again!
-
pages.clone() doesn't clone repeater-fields
bernhard replied to Dennis Spohr's topic in API & Templates
That's not true, please could you prove your statements with screenshots or the like and not just tell "it's not working"? And the current DEV: Recursive: You're welcome ? Yep, no reason not to use it IMHO.