-
Posts
6,671 -
Joined
-
Last visited
-
Days Won
366
Everything posted by bernhard
-
Thank you @Robin S for that snippet! One can also use fontawesome icons with this service: https://gauger.io/fonticon/ Just download the .ico to your website and include it like robin showed above: $this->addHookAfter('AdminTheme::getExtraMarkup', function($event) { $extras = $event->return; $extras['head'] .= '<link rel="shortcut icon" href="/site/templates/img/favicon.ico">'; $event->return = $extras; }); ?
-
How to find some hooks firing in the background?
bernhard replied to bernhard's topic in General Support
Thx @Autofahrn, but my quick test was at first glance nice, but it seems it is not 100% what I want... I put this hook in ready.php $this->addHookBefore("ProcessPageView::finished", function() { bdb(debug_backtrace(), 'finished'); }); This looked ok, but then I cloned my site and the "coneInvoide()" method did not show up in the backtrace. I did a debug_backtrace() in that method and - of course - it showed up there and showed a somewhat helpful dump. BUT: The problem is, that often I don't know what is going on where, so you can't just place a debug_backtrace() somewhere in the code, because you simply don't know where you'd have to put it. Do you know what I mean? Maybe I have to give xdebug another try... -
How to find some hooks firing in the background?
bernhard replied to bernhard's topic in General Support
Hi @Autofahrn, thx for that suggestion. I did not try that. But I'm not sure how I should/could do that to get a helpful output? I've found the issue, but would still be interested in a way to show a backtrace of all executed hooks ? I've added a file_put_contents(... FILE_APPEND) to WireHooks::runHooks() to dump all executed hooks to a file called hooks.txt. That could be a first step in the direction that I wish would exist already. The issue in my case was that my CRM module was loaded twice, so all methods added via hooks actually ran twice. I found that by inspecting the debug mode tools, where my cloneInvoice() method showed up twice (and so did all other CRM hook methods). The solution was to make the module "singular" (and do a module refresh). But still I think it would be great to have a chronological list of all executed hooks so that one can instantly see which hook fired when (and after/before what other hooks). -
Hello everybody, I have this allegedly simple hook to clone an invoice: public function cloneInvoice($event) { // check if this invoice is valid to clone $old = $event->object; if($old->template != 'invoice') throw new WireException("This is not a valid invoice to clone!"); // create clone $new = $this->pages->clone($old); $new->invoicenum = null; $new->date = time(); $new->datedue = null; $new->datesent = null; $new->datepaid = null; $new->pdfs->removeAll(); $new->save(); // return newly created page $event->return = $new; } The problem is, that $this->pages->clone() creates TWO copies of the page. There must be some other hook firing on page save or the like. But I can't find which one it is and I wonder how you debug such things? I've once tried something that I called hook-recorder, but that project never saw the light of day. Are you using XDebug? Or are there any tools that can help in such situations? Tracy maybe? The only thing that I know so far is that the code above fires ONCE but creates two copies. Thank you for your time ?
-
Not sure if anybody is watching what's going on in the requests repo or here in the forum... nevertheless, if you find this idea good, please support it on github: https://github.com/processwire/processwire-requests/issues/305
-
- 2
-
-
Hi @wiredny, welcome to the forum. Please be more precise. What navbar are you talking about? Are you using one of the default site profiles? Can you share the code that is rendering the menu?
-
Hi Beluga, is this a tabulator grid? Is it a custom module or the rockgrid extension you've linked some time ago? Regarding your join: I think in that case it would be the easiest to join them via plain sql; Something like $foo = $finder1->getSQL(); $bar = $finder2->getSQL(); $sql = "SELECT * FROM ($foo) AS foo LEFT JOIN ($bar) as bar ON (foo.col1 = bar.col1 AND foo.col2 = bar.col2)"; $this->setData($sql); PS: Be careful when joining / listing tables that have same name columns! This can lead to different results in the grid than in the resulting sql table. Compare the results to a regular SQL client by copying the resulting sql and executing it in Adminer and similar...
-
Important security update! Hi RockGrid users, I'm very sorry for that, but I have to announce a security update. If you are using RockGrid on a public site please upgrade to v0.0.22 (Fieldtype) immediately. It is a simple but important update: https://github.com/BernhardBaumrock/FieldtypeRockGrid/commit/0be2086139c84f775937246ed2985ac4c4a3e9c3; The proplem exists on all RockGrid fields with AJAX turned ON. In this case it was theoretically possible to expose the field data to a user that should not be allowed to see this data (in the worst case even a guest user) if the user knew how to do it and he also knew the name of the rockgrid field. The update now restricts access for AJAX field data to superusers only. You can easily adjust that via simple hooks: // rockgrid access control $wire->addHookAfter("InputfieldRockGrid::access", function(HookEvent $event) { // all grid data is accessible for all logged in users $event->return = $this->user->isLoggedin(); }); Or more granular via the fieldname: // rockgrid access control $wire->addHookAfter("InputfieldRockGrid::access", function(HookEvent $event) { $field = $event->arguments(0); $user = $this->user; $access = $event->return; switch($field) { case 'field1': case 'field2': case 'field3': $access = $user->isLoggedin(); break; case 'field4': $access = ($user->name == 'foo'); break; } $event->return = $access; }); Field 1-3 is allowed for logged in users, field4 only for user foo and all other fields only for superusers (default rule). I'm not totally happy any more with several aspects of RockFinder and RockGrid, but it is the best option I have so far (until I can build something totally new, maybe with tabulator if tests work well). Special thx to @Zeka for bringing this issue to my attention by coincidence in the other topic!
-
MathParser adds Intelligence to your Number Inputfields
bernhard replied to bernhard's topic in Modules/Plugins
Thx @LostKobrakai for pointing me to the right spot in the docs! I use math.format with a precicion of 14 now for all calculations. v0.0.6: v0.0.7: -
RockSkinUikit - Easily and quickly skin your AdminThemeUikit backend
bernhard replied to bernhard's topic in Modules/Plugins
Not sure I understand your question. Why don't you just look them up in the css files or browsers devtools? -
Interesting topic, I'll need this soon. RockGrid is sending Requests to the current page appending ?field=myfield so that it makes sure it gets loaded (even if it's set to ajax). But I want to take a different route for the next version. It's easier and cleaner to have one single endpoint url imho. I think @Robin S mentioned that somewhere but can't find it..
-
It's a WIKO phone, Android + Chrome https://www.amazon.de/gp/product/B01EM2SUL2/ Another thing I just found: https://mawsonshuts.antarctica.gov.au/preparation/australia-and-antarctica/ The edited date is in the footer, so for me this seems like the whole website was last updated in 2011... Maybe that could be moved to the content block of the site.
-
File Upload inside Custom Module
bernhard replied to SoccerGuy3's topic in Module/Plugin Development
Just try it without and see what happens: Nothing ? If you are not on a page edit screen PW doesn't know where to upload your file so you need do tell it manually. You could also do a move_uploaded_file() but that does not sanitize your data. -
File Upload inside Custom Module
bernhard replied to SoccerGuy3's topic in Module/Plugin Development
Whenever you need something think "Where is it done in the core" and grab ideas from there ? You can see how it is done in ProcessModuleInstall.php I've done it that way recently: $tmpDir = $this->files->tempDir('upload_csv'); /** @var InputfieldFile $f */ $f = $this->modules->get('InputfieldFile'); $f->attr('id+name', "upload_csv"); $f->label = 'foo'; $f->icon = 'download'; $f->extensions = "csv"; $f->maxFiles = 1; $f->descriptionRows = 0; $f->destinationPath = $tmpDir; // when the form is submitted: /** @var WireUpload $ul */ $ul = $this->wire(new WireUpload($f->name)); $ul->setValidExtensions(explode(" ", $f->extensions)); $ul->setMaxFiles($f->maxFiles); $ul->setOverwrite($f->overwrite); $ul->setDestinationPath($f->destinationPath); $ul->setExtractArchives(false); $ul->setLowercase(false); $files = $ul->execute(); if(count($files)) { $file = $f->destinationPath . reset($files); // do something with your file } else { $this->error('No uploads found'); } There is an issue with ajax loaded fields: https://github.com/processwire/processwire-issues/issues/885 And it seems that ZIP is always added to the allowed file endings... Can anybody confirm that? PS: Don't you use TracyDebugger? It's a lot better than using print_r() ? -
https://github.com/processwire/processwire/tree/master/site-blank/templates https://github.com/processwire/processwire/tree/master/site-beginner/templates https://github.com/processwire/processwire/tree/master/site-classic/templates https://github.com/processwire/processwire/tree/master/site-default/templates https://github.com/processwire/processwire/tree/master/site-languages/templates https://github.com/processwire/processwire/tree/master/site-regular/templates Just compare your folder/file structure with the original one, especially /site/templates/readme.txt
-
MathParser adds Intelligence to your Number Inputfields
bernhard replied to bernhard's topic in Modules/Plugins
Hi @LostKobrakai I don't know ? https://mathjs.org/ Could you explain a little more verbose please why you think that parsefloat is a problem? For all my use-cases I can think of, this is exactly the output I want to get... -
MathParser adds Intelligence to your Number Inputfields
bernhard replied to bernhard's topic in Modules/Plugins
v0.0.6 adds support for runtime fields, that means you can now use mathparser in your processmodules as well just by specifying one property: /** @var InputfieldDecimal $f */ $f = $this->modules->get('InputfieldDecimal'); $f->label = "foo"; $f->attr('id+name', "bar"); $f->mathParser = true; -
Thx for sharing and congratulations for the great site! Interesting approach for the menu! I tested it on mobile and found this little hickup (and spacings could also be removed): Also I'd suggest to list all children at the bottom of those pages: https://mawsonshuts.antarctica.gov.au/preparation/australia-and-antarctica/ (not only next and previous). For me it was not clear that the two links at the bottom belong to one parent (as seen very well in the menu). You can have a look how I did it here: https://www.maletschek.at/segelmacherei/persenning/cockpitpersenning/
-
Sorry, I don't get what you are saying ? BTW: Of course you can just show a simple grid without modifying it via javascript. That's explained in the quickstart: https://github.com/BernhardBaumrock/FieldtypeRockGrid/wiki/Quickstart (actually there is nothing to explain if you don't use any javascript modifications). But as soon as you want to style or tweak your grid (eg custom Headernames) you need javascript. Would be happy to see some screenshots so maybe others do also get inspired by your work ?
-
Hi @gottberg glad to hear that. Sometimes I feel that the potential of this or similar modules is underestimated. If you only need a HTML grid (table) then you might be better off using MarkupAdminDataTable. RockGrid is by design a grid with user input like filtering and sorting and custom colorizations based on cell values. If you don't need all that just create a plain html table. Does that help?
-
[solved] Help with AJAX loaded InputfieldFile in ProcessModule
bernhard replied to bernhard's topic in General Support
I found the issue! I'll file a report on github and link it here when I'm done. https://github.com/processwire/processwire-issues/issues/885