Jump to content

netcarver

PW-Moderators
  • Posts

    2,236
  • Joined

  • Last visited

  • Days Won

    47

Everything posted by netcarver

  1. http://modules.processwire.com/modules/admin-hot-keys/
  2. Function Allows all admin-side text areas to auto-expand as they are used. Description Following on from tpr's mini-tutorial, I went ahead and wrapped it up as a module. I'm re-posting it here in the module's forum and will submit it to the module repository to prevent it from becoming one of PW's "ghost" modules - modules for PW that exist on github (or elsewhere) and have a relatively obscure link from the forum or a blog post somewhere else. Links The module on Github. The module in the module repository. Version History 1.0.0: Initial release.
  3. Yup, just like that.
  4. If you take a view on what day a week starts on, you can use the PHP function strtotime() to get the timestamp of the last time that day happened and format it using date() to get it as a string for use in your find/filter selector. For example, if you decide a week starts on Monday, then this should get you a value you can use in selectors... $when = 'Last Monday'; $timestamp = strtotime($when); $date = date('Y-m-d', $timestamp); //echo "The date $when was $date\n"; Untested, YMMV.
  5. Now available as a module on Github.
  6. @nixsofar, Really glad you got that tracked down; congratulations. Could you share with us any tips about how you went about finding this? Did you notice a huge number of stack frames in some tool or other? Or was it from single-stepping using Xdebug? Something else entirely? Always interested in the critical thinking skills and tooling that can help track down bugs. Thanks! Steve
  7. Ouch. This is getting out of my area of experience. There are a couple lines of enquiry I'd look at now... diff the virtual host files for a working site vs the one that segfaults and look for any potential differences diff a working .htaccess vs the segfaulting site Start looking at how to debug a segfault in apache. Sorry, I can't be of more help - but please post what you do and what you find out. Good hunting! Steve
  8. Is the prepend file, required by that template, actually in the correct place? Using die("$_filename"); before the require(...); might point you in the right direction. Hope that helps. Steve
  9. Hello holmescreek, With people having such busy schedules these days, why not fork the module & make any necessary changes to your GitHub repository. You don't have to advertise your fork, or even enter it into the module repository. You could, instead, issue a pull request to the original repository so that Ryan could then see how much/little needs to be done to add your change back into the official module. Once the changes get incorporated, it is then just a matter of deleting your GitHub repository. Best wishes, Steve
  10. @marcus, No problem, thank you for your time on this and for your reply; I hope you feel better soon. Regards, Steve
  11. Any timescales on PW3 compatibility?
  12. To extend the above example to hide the name, template and parent fields on the settings page of invoices, you can add the following to the ready.php snippet in the above post. /** * Work out if the template's settings should be tweaked to hide things that should be fixed... */ function shouldHideTemplateSettings() { // Super users retain super-setting-edit powers if (wire('user')->isSuperUser()) { return false; } // Are we even editing a page? if (wire('page')->process != 'ProcessPageEdit') { return false; } $id = (int) wire('input')->get('id'); if (!$id) { return false; } $editedPage = wire('pages')->get($id); if ($editedPage->template->flags & Template::flagSystem) { return false; } if (!isInvoiceTemplate($editedPage->template->name)) { return false; } return true; } /** * Hide some fields from the invoice settings page from non-super-users. * * There's not much point allowing edits to the name field, so we want it immutable (at least) and probably totally * hidden (better.) * * We don't want invoices being moved from their parent, so we hide the parent field. * We don't allow them to use a different template, so we hide the template field. * */ if (shouldHideTemplateSettings()) { $pages->addHookAfter("ProcessPageEdit::buildFormSettings", function($event) { $wrapper = $event->return; // To show the name field but make it immutable $wrapper->_pw_page_name->collapsed = Inputfield::collapsedNoLocked; $wrapper->_pw_page_name->description = ''; // Alternatively, to hide the name field do uncomment the following and comment out the 2 lines above //$wrapper->_pw_page_name->collapsed = Inputfield::collapsedHidden; // Hide the template changer, invoices can only use the invoice template $wrapper->template->collapsed = Inputfield::collapsedHidden; // Hide the parent page, as it is fixed in our page structure $wrapper->parent_id->collapsed = Inputfield::collapsedHidden; }); }
  13. Hi Ben, Just wanted to say thank-you for this module. I'm trying it out now and am really liking it!
  14. As promised, here's a link to my module that RyanJ's been helping to test out.
  15. This module provides a very simple interface to a set of named counters. You simply call a single function, next('name'), to pull the next value out of a counter - or to set it up if it does not yet exist. Next() takes a few extra parameters to allow you to increment by values other than 1 or to start at a certain number. This provides some similar functionality to the built-in page naming feature of PW, and to this module recently posted by Stikki but I think it offers a little more flexibility than either. Having said that, I do like the simplicity of Stikki's new auto-increment module. Module Availability Here is my module on Github. Here it is in the module repository. Example Usage Here's how this module can be used to title and name a new page by adding a couple of simple hooks to site/ready.php. This example applies to new pages using a template called 'invoice' that can be quick-added to the page tree. In order to get the following to work, you must edit the template that will be the parent of the 'invoice' template and setup the template for children to "invoice" and set the "Name Format for Children" field to something other than the default blank value (I use title as my value.) <?php /** * Function to recognise our special template. */ function isInvoiceTemplate($template) { return ($template == 'invoice'); } /** * Pre-load the page title for invoice pages with a unique value * which includes a counter component. */ $pages->addHookBefore("Pages::setupNew", function($event) { $page = $event->arguments(0); $is_invoice = isInvoiceTemplate($page->template); $no_inv_num = $page->title == ''; if ($is_invoice && $no_inv_num) { $counter_name = 'WR-' . date('Y'); $number = $this->modules->get('DatabaseCounters')->next($counter_name, 10, 5000); $page->title = $counter_name . '-' . sprintf("%06u", $number); } }); /** * Prevent ProcessPageEdit from forcing an edit of the name if we got here * through a quickAdd from ProcessPageAdd. We can do this because we * preset the title field in the Pages::setupNew hook. */ $pages->addHookAfter("ProcessPageEdit::loadPage", function($event) { $page = $event->return; $is_invoice = isInvoiceTemplate($page->template); $is_temp = $page->hasStatus(Page::statusTemp); if ($is_invoice && $is_temp) { $page->removeStatus(Page::statusTemp); $event->return = $page; } }); Note, the above code + module is one direct solution to the problem posted here by RyanJ. Version History 1.0.0 The initial release.
  16. I've PM'd my module over to Ryan for testing. Let's see what comes of it over the next couple of days. If it works out we'll post updates here.
  17. Can't write a long reply at the moment, but your approach is not thread safe (as far as I can tell.) What would happen if another user added some other page between the calls to your two working hook functions? I have a module that can help. Will post more tomorrow. Goodnight!
  18. Bookmarking: https://processwire.com/blog/posts/making-efficient-use-of-fields-in-processwire/
  19. Adrian, Many thanks for this debugger. It. Is. Fantastic! Could I request the xdebug integration, please.
  20. Sorry to hear about your loss, GM.
  21. There is a keyframe animation module for PW, if interested.
  22. @Nukro, How about using kongondo's wonder-field module (instead of a summary field) and have it access the value you want?
  23. @adrianmak, Have you taken any steps to try to solve this issue yourself?
  24. Ferdi, thank you!! Always good to see new module authors writing for PW.
  25. Having just read this... ...(source.) It seems that you could run your hook directly from the init.php file and be done with your module (if needed.) You could, at least, use init.php to test your intercept routine.
×
×
  • Create New...