-
Posts
6,629 -
Joined
-
Last visited
-
Days Won
358
Everything posted by bernhard
-
VSCode in my home.php template file (note the marked php start and end tag because I had my cursor there which is not visible in the pic): That's ok because the green parts are just strings for your IDE! Same with VSCode: I think you should have a look at https://processwire.com/api/ref/files/render/g/ Take this example: And in your invoicetemplates.php file you could have clean code just like this: Why not give VSCode a try? ?
-
Maybe you want to paste code snippets and a screenshot to help us understand your problem better? I'm using VSCode and it looks like this: Another example with a multiline concatenated string: And another one appending some infos to a rendered field value:
-
Are you talking about a link to the docs or about shortcut links to the settings page of the template where the admin can adjust those permissions? The latter would be great! Maybe there could also be a section where it shows which template setting is responsible, eg: path | template | active -----------------|--------------|-------------------------------- / | home | yes /foo | basic-page | yes /foo/bar | whatsoever | no (inherited from basic-page) The template strings could be linked to the access tab of the template settings. Not sure how complicated that would be to implement, but I think it could be helpful ? +1 for some more thoughts on the colors! I think the red is too loud. It's not a warning imho - it's just telling there is no permission. I think the red could be removed completely. I'm fine with the green - although I think it could also be more quiet...
-
Hi, seems you need something VERY similar to one of my projects: https://www.grafikgesellen.at/textilien/gwaund-fuer-oesterreicha/landkarten-shirt/ Is it a commercial project? If you are interested in a siteprofile just send me a pm.
-
That's because of the way markup regions work: See the link to the github issue and ryans explanation. +1 for using Tracy, like Robin mentions in the post.
-
created another useful snippet to reset the admin password: "Reset Admin Password": { "prefix": "reset", "body": [ "\\$admin = \\$users->get(41);", "\\$admin->setAndSave('pass', '$1');", "die(\"admin url = {\\$pages->get(2)->httpUrl}, admin username = {\\$admin->name}\");", ], "description": "Reset Admin Password" },
- 246 replies
-
- 2
-
-
- visual studio code
- vsc
-
(and 2 more)
Tagged with:
-
hi @kongondo sorry for being unclear. I played around a little and came up with this solution: I think that's a quite good solution. It's easy to type, easy to read and it is efficient, multi-instance ready and supports code completion (and is always in sync with your current pw version)... What do you think? // php.json "Import PW Module": { "prefix": "mod", "body": [ "$$1 = \\$this->wire->modules('$2'); /** @var $2 $$1 */", "$$1$0" ], "description": "Import PW Module" }, "Get Wire Instance": { "prefix": "wire", "body": "$$this->wire->$0", "description": "Get Wire Instance" },
- 246 replies
-
- 3
-
-
- visual studio code
- vsc
-
(and 2 more)
Tagged with:
-
Thx again! For proper code completion I'd prefer $this->wire->scripts instead of $this->wire('scripts') - would that also be ok?
-
I did some more testing and got one step further. You might also be interested in this thread regarding intellisense: I can now answer my question of the day before yesterday: The correct syntax is this: /** @var InputfieldButton $button */ This way you get proper code completion even for your very own variables. @kongondo do you think you could do (or guide me how to do it) a snippet that adds the IDE variable type hints automatically? This could improve the workflow and code completion even more. For example here I define a RockGrid as variable $f and with the /** @var ... */ comment I get the suggestion of "setData()" method for my grid:
- 246 replies
-
- 2
-
-
- visual studio code
- vsc
-
(and 2 more)
Tagged with:
-
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: