Jump to content

Robin S

Members
  • Posts

    5,007
  • Joined

  • Days Won

    333

Everything posted by Robin S

  1. But this isn't a solution for touch devices which don't have a hover state, and we all know that touch devices are a big share of internet use. There's discussion in the Invision Community support forums about how to bring back reputation points into the author pane (some of which I can't see but maybe @Pete can)... https://invisioncommunity.com/forums/topic/462326-current-ranks-–-and-–-reputation/ https://invisioncommunity.com/forums/topic/462099-bring-back-reputation-in-userinfopane/ Could we implement that here? Also, it would be nice to bring back custom member titles for those who had them (e.g. Ryan's reiska title): https://invisioncommunity.com/forums/topic/462409-46-how-to-restore-custom-member-titles/
  2. Not sure if it's just a forum typo but you should only have quotes around the key - it should be: $page->save(['noHooks' => true]); It seems to be working here for me. The PhpDoc comments form the basis of the online documentation: https://processwire.com/api/ref/pages/save/ So you're right that it wouldn't be hard to miss but it's not buried in the sense that you'd only find it by examining the core files. As a general thing, if you call any hookable method and include the underscores at the start of the method name then any hooks to that method won't be triggered. So I think the idea here is that the noHooks option takes care of making sure that several potential downstream hooks wont fire (e.g. Pages::saveReady, Pages::savePageOrFieldReady, Pages::saved, Pages::savedPageOrField, Pages::added) but in case Pages::save was itself hooked you'd need to call it with the underscores to prevent that hook from firing. But what's interesting is that the core itself doesn't call Pages::___save (with the underscores) when you do call Page::save() with the noHooks option true, and likewise with Pages::___saveField. Maybe the documentation for the noHooks option should be expanded to explain exactly which hooks are avoided, or the core should call Pages::___save and Pages::___saveField with underscores when noHooks is true. @ryan?
  3. Not a response to your code, but more a general suggestion... If the point of this is to restrict what editors can do in the PW admin then I think it would be cleaner and a better experience for editors if you focus on making the admin UI conform to your restrictions. In other words, if the user may not change a page's name or template then don't show those fields in Page Edit, or set them to readonly (I seem to remember that the name input needs to remain in the Page Edit form). And if the user may not sort a page then don't show the "Move" item in page lists. You should be able to achieve this with hooks to methods such as ProcessPageEdit::buildForm() and ProcessPageListActions::getActions().
  4. Double-check that the path to your JS file is correct, because that conditional will only append the script markup if is_file() is true. With some debugging (see item 2) hopefully you can get it working. I just tested here again and it works for me. The label of that config setting is perhaps not perfect - I'll update it. The setting doesn't actually ensure that Tracy is displayed, rather it only disables the default CSS in the module that would otherwise hide the Tracy debug bar. <?php if(!$hcd->show_tracy): ?> #tracy-debug { display:none !important; } <?php endif; ?> So you first need to have Tracy set to display the debug bar in the PW admin generally and then if you have that HCD setting checked it won't be hidden in the dialog. There's not much I can do about that because it's just how the CKEditor Widget plugin works. In such a situation I tend to use the arrow keys to move the cursor to the start of the field, or type the text underneath and then drag the widget to its new position.
  5. Technically files on any page are available to link to on any other page. You use the "Select Page" field to choose the page that holds the file you want to link to and then select a file from that page. But to make it quicker to select files from one or more special "library" pages there is this handy module: https://processwire.com/modules/media-library/
  6. You will get the URL to the image variation (small image) from the src attribute of the <img> tag. When you have that variation URL you can use it with PagefilesManager::getFile() to get the Pageimage (see here), and from the Pageimage you can get the original URL by $pageimage->url
  7. Here is a simple proof-of-concept Textformatter that might help: You can adapt the example in the readme to add a lightbox link to your images.
  8. Process Images A basic, proof-of-concept Textformatter module for ProcessWire. When the Textformatter is applied to a rich text field it uses Simple HTML DOM to find <img> tags in the field value and passes each img node through a hookable TextformatterProcessImages::processImg() method. This is a very simple module that doesn't have any configurable settings and doesn't do anything to the field value unless you hook the TextformatterProcessImages::processImg() method. Hook example When added to /site/ready.php the hook below will replace any Pageimages in a rich text field with a 250px square variation and wrap the <img> tag in a link to the original full-size image. For help with Simple HTML DOM refer to its documentation. $wire->addHookAfter('TextformatterProcessImages::processImg', function(HookEvent $event) { // The Simple HTML DOM node for the <img> tag /** @var \simple_html_dom_node $img */ $img = $event->arguments(0); // The Pageimage in the <img> src, if any (will be null for external images) /** @var Pageimage $pageimage */ $pageimage = $event->arguments(1); // The Page object in case you need it /** @var Page $page */ $page = $event->arguments(2); // The Field object in case you need it /** @var Field $field */ $field = $event->arguments(3); // Only for images that have a src corresponding to a PW Pageimage if($pageimage) { // Set the src to a 250x250 variation $img->src = $pageimage->size(250,250)->url; // Wrap the img in a lightbox link to the original $img->outertext = "<a class='lightboxclass' href='{$pageimage->url}'>{$img->outertext}</a>"; } }); GitHub: https://github.com/Toutouwai/TextformatterProcessImages Modules directory: https://processwire.com/modules/textformatter-process-images/
  9. That sounds like a JavaScript issue - have a look for errors in the browser console. I just checked with the latest PW/HannaCode/HannaCodeDialog and it all seems to be working here.
  10. This feature sort of exists already, and it's set on the parent template. If a template is allowed to have only a single child template then there is a setting "Name format for children" available on the "Family" tab. Info: https://processwire.com/docs/modules/guides/process-template/ There is a module that extends the feature: But my preference is to just set a date format like "Y/m/d H:i:s" for "Name format for children" and then set the final title/name in a hook to Pages::added, e.g. $pages->addHookAfter('added', function(HookEvent $event) { /** @var Page $page */ $page = $event->arguments(0); if($page->template == 'your_template') { // Set whatever you want the title and name to be $page->of(false); $page->title = "Page ID: $page->id"; $page->name = $event->wire()->sanitizer->pageName($page->title, true); $page->save(); } }); Unfortunately "modified" and "created" cannot be used in a Pages::added hook because these properties are not populated on new pages until the next request. But you could use time(), or subsequently use the modified/created properties to set the title in a Pages::saveReady hook.
  11. @Pete, the reputation count seems to have disappeared (Ryan's is around 20K). Deliberate? Also, the rocket that is poking everyone in the face looks stupid. Can we lose that? Like, what exactly is a "hero" member anyway and does anyone really care about that status? ?
  12. You could edit /site/templates/admin.php so that it looks something like this: // Get the user's IP address $ip = $session->getIP(); // Define the allowed IP addresses $allowed_ips = ['111.111.111.111', '222.222.222.222']; // Check user's IP is allowed if(!in_array($ip, $allowed_ips)) { return 'Access denied'; } require($config->paths->adminTemplates . 'controller.php');
  13. Given how simple FieldtypeRuntimeOnly is, it might be good to avoid the dependency in your module and just render your own markup directly. I haven't looked closely at your module but it just seems like it would make sense to keep it self-contained and avoid any fragility due to the chance that FieldtypeRuntimeOnly changes in the future.
  14. I can't reproduce that. It's showing collapsed => 4 when I dump the field in a FieldtypeRuntimeOnly render file. This module doesn't do anything regarding inputfield visibility so I think your issue must be a general one relating to the PW API rather than specific to this module. Really all this module is doing is rendering a TemplateFile via $files->render(). One thing though... take note of the readme regarding the variables supplied to the render file: I don't know if it relates to your issue but I suggest you avoid overwriting the $field variable by choosing a different name for the field you are getting.
  15. Here's a hook that might help: $wire->addHookBefore('ProcessModule::executeEdit', function(HookEvent $event) { if($event->wire()->input->get('name') !== 'YourModuleName') return; $event->wire()->addHookBefore('InputfieldForm::render', function(HookEvent $event) { /** @var InputfieldForm $form */ $form = $event->object; if($form->id !== 'ModuleEditForm') return; $your_module = $event->wire()->modules->get('YourModuleName'); if($your_module->foo === 'bar') { $uninstall = $form->getChildByName('uninstall'); $uninstall->description('You may not uninstall this module because foo equals bar.'); $uninstall->attr('disabled', 'disabled'); } }); }); Update: an example in the context of your module... public function ready() { $this->addHookBefore('ProcessModule::executeEdit', $this, 'disableUninstall'); } protected function disableUninstall(HookEvent $event) { if($this->wire()->input->get('name') !== $this->className) return; $this->wire()->addHookBefore('InputfieldForm::render', function(HookEvent $event) { /** @var InputfieldForm $form */ $form = $event->object; if($form->id !== 'ModuleEditForm') return; if($this->foo === 'bar') { $uninstall = $form->getChildByName('uninstall'); $uninstall->description('You may not uninstall this module because foo equals bar.'); $uninstall->attr('disabled', 'disabled'); } }); }
  16. In my opinion the best solution would be to use a ProFields Table field because it has less overhead than pages and everything is viewable inside a single compact inputfield. But if you go with a page-based approach (which will be just fine if not 100% optimal) then your options are: Repeater PageTable Child pages Another opinion: purchasing the ProFields bundle should be a no-brainer for any regular PW user. Any one of the Table, Repeater Matrix and Combo fieldtypes alone is worth the purchase price, but you get all of them, plus several more goodies which are just cherries on the top. And as Ryan explained in the most recent blog post, the purchase of Pro modules is an important part of what keeps the ongoing development of PW viable. So it's a nice way to play a part in that. ?
  17. @ryan, regarding the update to ProcessWireUpgrade, could you please add an option to skip this interstitial screen? Because it doesn't add much value and just requires an extra click. If you are visiting the Upgrades page it already implies that you want to load the latest core and module versions to check if there are any upgrades available and the few seconds needed isn't going to be a big deal to you. Thanks.
  18. If you have the "Preset field values from GET variables?" setting checked you can use embed option B (Template Embed) and set field values in a second argument to $forms->embed() echo $forms->embed('your_form_name', [ 'vacancy' => $page->title, 'pageid' => $page->id ]);
  19. If you're seeing an uncaught exception (i.e. an error screen) and have the latest version v4.22.5 Tracy Debugger installed then you might be affected by this issue: https://github.com/adrianbj/TracyDebugger/issues/59 (Update: fixed now in v4.22.6, thanks @adrian) But there's also a core bug that makes the "Move" action appear in Page List in situations where it shouldn't, and I've opened a GitHub issue and suggested fix for that here: https://github.com/processwire/processwire-issues/issues/1394
  20. It sounds like it might be a namespace issue. Check that your template files and included files start with: <?php namespace ProcessWire; FileCompiler tries to automatically fix files that don't declare the PW namespace but I think the most reliable approach is to always add it yourself.
  21. Create a new permission named "page-lister-lister" to signal that you want to have access control over the Find lister. Then you can give that permission to any roles that you want to be able to access the Find lister, and other roles won't be able to access it.
  22. It's working here for me. $config->sessionAllow = true; $config->sessionAllow = false;
  23. Read about the $config->sessionAllow option here: https://processwire.com/blog/posts/multi-instance-pw3/#more-session-control
  24. Very cool, thanks @bernhard and @ryan! Any thoughts about supporting an SCSS version of AdminThemeUikit and customising via an admin.scss file? Uikit offers a Sass (SCSS) version and my impression is that SCSS is more popular than LESS. Google Trends: One person's opinion from 2015: https://www.telerik.com/blogs/why-bootstrap-4-means-sass-has-won It would be interesting to conduct a poll of PW users to see which is the more popular CSS pre-processor.
  25. Rather than being nonsense, it actually tells you exactly what you need to do to fix the situation: But maybe you haven't learned about translations in PW yet so you don't understand. For each language in your site, navigate to Setup > Languages > [your language] and in the "Core Translation Files" field click the "Find Files To Translate" button. Then locate the LanguageSupport.module, click on it to highlight it, and click the "Submit" button. Then locate the "C" item and translate it to the value that should be set via setlocale(LC_ALL, [value]) for that language. Now click "Save".
×
×
  • Create New...